Filters
Filters are programs that take plain text(either stored in a file or produced by another program) as standard input, transforms it into a meaningful format, and then returns it as standard output.
Linux has a number of filters. Some of the most commonly used filters are explained below:
cat
cat // Displays the text of the file line by line.
Ex: cat file.txthead
head // Displays the first n lines of the specified text files.
Ex: head file.txttail
tail // It works the same way as head, just in reverse order.
Ex: tail file.txtsort
sort // Sorts the lines alphabetically by default.
Ex: sort file.txtuniq
uniq // Removes duplicate lines.
Ex: uniq file.txtwc
wc // wc command gives the number of lines, words and characters in the data.
Ex: wc file.txtgrep
tac
sed
It allows us to apply search and replace operation on our data effectively. sed is quite an advanced filter and all its options can be seen on its man page.
The expression we have used above is very basic and is of the form ‘s/search/replace/g’
nl
Last updated