Forum

Notifications
Clear all

shell question  

   RSS

0

any help? thanks

3 Answers
0

You are in the shell. We have a file called ‘sample’. We want to highlight only the lines that do not contain the character ‘a’, but the result should be in reverse order. We then want to write the resulting output to a file called ‘myoutput’.

What commands do you issue to shell? (Use Cat, Grep and Sort Commands to help you)

 

0
Hi @Blastbeak! Here are some hints.
 
1. grep is used for finding lines which match a pattern. If you want to find lines which don't match a pattern, you can use the -v option. The syntax is like this:
 grep targetword file_to_search_in -v
 
2. sort is used to sort lines. In order to sort in reverse order, you can use the -r option. The syntax is like this:
 
sort -r my_file_to_sort
3. In this exercise, you want to sort the output from the grep, so you need to pipe (|) the output to sort, which looks something like this:
 
grep something | sort -r
 
4. To write the output to a file, you can use >. The syntax is like this:
 
"some text" > my_output_file
 
Hopefully the above is sufficient to help you solve this. Good luck!
0

We have reviewed the question and amended it to a multiple choice question as it is too open-ended for a fill in the blank question.

Share:

Delete your account