Practice: Text Challenge
Tr, sed and friends.
One last challenge for the text tools. This one uses the team file, a small CSV. Read the tasks, and try each one before you watch the answer.

- One last text challenge
- A small CSV file
- Try each task first
The tasks
Task one. Print only the names, without the header line. Task two. Show the file with every role in capital letters. Task three. Count how many people live in London. Pause, and try all three.
Some answers
Tail dash N plus two starts from line two, which skips the header, and cut takes the first field. For task two, awk with a comma separator, and the toupper function, capitalises the second field. And grep dash C London counts two people.
tail -n +2 team.csv | cut -d, -f1 sam alex jo priya awk -F, 'BEGIN{OFS=","} {$2=toupper($2); print}' team.csv name,ROLE,city sam,DEVELOPER,London alex,DESIGNER,Paris jo,DEVELOPER,Berlin priya,MANAGER,London grep -c London team.csv 2
There is always another way
Don't worry if your answer looked different. On Linux, there are usually several ways to do the same thing. If your command gave the right result, it's a right answer. Over time, you'll find the tools you like best.
| key | value |
|---|---|
| Many ways | to do the same job |
| Right result | is a right answer |
| Your favourites | you'll find them |
| Practice | makes it natural |
Summary
That's the end of the text tools section. You can search, count, slice, and change text like a pro. Next, a new section. Users and permissions.
Key takeaways- grep, cut, awk
- sort, uniq, tr, sed
- Pipelines