Common Script Utilities
Common Script Utilities
tail
The tail command prints the last n lines of a standard input or file. We can use the following command to print the last lines of the results of the ls -l
command. ls -l | tail -3
We can also combine the head and tail commands to retrieve the lines in between. Let’s pull lines of the ls -l command by:
Retrieving the first lines with head -10, then
Get the last lines of that result with tail -5, giving us lines We can combine these requests into the following single command:
ls -l |head -10 |tail -5
wc
-w: Displays only the word count and file name.
wc -w pres_first.txt
-c: Displays only the byte count and file name.
wc -c pres_first.txt
-l: Displays only the line count and file name. wc -l pres_first.txt
-m: Displays only the character count and file name. wc -m pres_first.txt