A Quick Introduction to Unix/exercises4

From Wikibooks, open books for an open world
Jump to navigation Jump to search


Task Seven

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.


What commands will accomplish task seven?
cat > list2
orange
plum
mango
grapefruit

Task Eight

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 Nine

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.