Use HEAD to output the first 10 lines of ‘foo.txt’ |
|
Use CAT and pipe the output to HEAD to print out the first 10 lines of ‘foo.txt’ |
|
Use TAIL to print out the last 10 lines of
‘foo.txt’ |
|
Use HEAD to print out the first 3 lines of
‘foo.txt’ |
|
Use CAT and SORT to output ‘foo.txt’ in sorted order. |
|
Use SORT (only) to output ‘foo.txt’ in sorted order. |
|
Use SORT and pipe to UNIQ to output only the unique entries in sorted order in ‘foo.txt’. |
1. head -n 10 foo.txt
first 10 lines of 'foo.txt' are displayed
2. cat foo.txt | head -n 10
initially foo.txt is read and then this is piped to the head
command which retrieves the first 10 lines and displays them
3. tail -n 10 foo.txt
last 10 lines are displayed
4. head -n 3 foo.txt
first 3 lines are displayed
5. cat foo.txt | sort
initially foo.txt is read and then the lines are displayed in
sorted order
6. sort foo.txt
displays file contents in sorted order
7. sort foo.txt | UNIQ
sorts the the file and then displays the unique lines in it.
Get Answers For Free
Most questions answered within 1 hours.