Challenge questions
Now test yourself on the tutorial! Here are a few tasks to try out.
Change directory to your home directory and create a new folder named 'challenges'. Then
cdinto it.Use
echoand redirection to create a file called 'days_of_week.txt', listing the days of the week, one on each line. After each day, write down whether it's a weekday or weekend. Your file should look something like this:
Monday weekday
Tuesday weekday
(etc)
Saturday weekend
Sunday weekend
Note: remember you can use ↑ and ↓ to navigate back through your commands - this may make this much faster.
Use
lessorcatto view the contents of the file and check they are correct. If not, use a text editor to fix any problems.Create a pipeline using
catandgrepandcut, to print out just the names of the weekdays. Note If your file is space-separated, like the one above, you will need to use the-f ' 'argument tocutto tell it to use spaces instead of<tab>characters. Check the man page forcutmore details.)Add to your pipeline a command to sort the weekdays in alphabetical order.
Finally, add a
trcommand to your pipeline that changes 'a' to '@'.
You should now should be looking at something like this:
Frid@y
Mond@y
Thursd@y
Tuesd@y
Wednesd@y
If so, well done! If not, look carefully back at your previous commands (for example using
history) to see if you can spot what went wrong.
Congratulations! This is the end of the tutorial.