Open main menu

Wikibooks β

A Quick Introduction to Unix/exercises4

< A Quick Introduction to Unix

Task SevenEdit

Using a text editor (or if you insist cat), create a file called list2 containing the following fruit: orange, plum, mango, grapefruit. Display the contents of list2.

Task EightEdit

Using pipes, display all lines of list2 containing the letter 'p', and sort the result. Search the file science.txt for the word ‘science’, sort the output and store it in a file (make up your own name for the file)

What commands will accomplish task eight?

% grep 'p' list2 | sort
% grep 'science' science.txt | sort > sortedscience.txt

Task NineEdit

Use the editor Pico to create a text file and name it as you wish. Try changing access permissions on the file you have just created and on the directory archive Use ls -l to check that the permissions have changed.