You can connect two commands together so that the output from one program becomes the input of the next program. Two or more commands connected in this way form a pipe. To make a pipe, put a vertical bar (|) on the command line between two commands.
When a program takes its input from another program, it performs some operation on that input, and writes the result to the standard output. It is referred to as a filter.
The following are some of the filter commands . Click the commands to see the man page and learn different options.
When a program takes its input from another program, it performs some operation on that input, and writes the result to the standard output. It is referred to as a filter.
The following are some of the filter commands . Click the commands to see the man page and learn different options.
wc- count number of lines words and characters
cut- cut the files vertically character or field wise
paste- vertically paste two files
head- get lines from the beginning of a file
tail-get lines from the end of a file
sort- sort the files contents
grep,egrep,fgrep- search file contents
uniq- unique lines from a sorted file
join- joining two files
tr- translating characters
awk-is a full-featured text processing
language
Sample scripts using filters
Display the file name and file size of regular files in the ascending order of file size
ls -l|tail -n +2|grep -v "^d"|tr -s ' '|cut -d' ' -f5,9|sort -n -k1Display the file name and file size of regular files in the ascending order of file size
Comments
Post a Comment