By: Vivek G. Viewed: 153263 times Printer Friendly Format
If a Linux command accepts its input from the standard input and produces its
output on standard output is know as a filter. A filter performs some kind of
process on the input and gives output. For e.g.. Suppose you have file called 'hotel.txt'
with 100 lines data, And from 'hotel.txt' you would like to print contains from
line number 20 to line number 30 and store this result to file called 'hlist'
then give command:
$ tail +20 < hotel.txt | head -n30 >hlist
Here head command is filter which takes its input from tail command (tail command start selecting from line number 20 of given file i.e. hotel.txt) and passes this lines as input to head, whose output is redirected to 'hlist' file.
Consider one more following example
$ sort < sname | uniq > u_sname
Here uniq is filter which takes its input from sort command and passes this lines as input to uniq; Then uniqs output is redirected to "u_sname" file.
Most Viewed Articles (in Linux )
Latest Articles (in Linux)
Comment on this tutorial
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews