Basic Linux Tutorial
Computer Tutorial

Filter ( tee, grep & cut ) Commands

Filter ( tee, grep & cut ) Commands


tee command are used to copying standard input to standard output and making a copy to one or more files.
Synopsis :
tee [option] file
Example :
echo   ‘yes’ | tee yes.txt
ls –l | tee abc.txt/wc –l
-a   append to the given file, do not overwrite
-i   ignore interrupt signal


The grep command are used to search text or search the given file for lines containing a match to the given string or words, by default grep display the matching lines.
Synopsis :
grep   [option]   pattern   files
Example :
grep   test   file.txt
-b   Display the block number at the beginning of each line.
-c   Display the number of matched lines.
-h   Display the matched lines, but do not display the filenames.
-i   Ignore case sensitivity.
-l   Display the filenames, but do not display the matched lines.
-n   Display the matched lines and their line numbers.
-v   Display all lines that do NOT match.


The cut command is used to select section of text from each lines of files. It can filter selected column from files, depending on a delimiter or a count of bytes.
Synopsis :
cut [option]   file name
Example :
cut   -f   2 - 4   file1.txt
-b   select only the byte from each line a specified in list.
-c   select only the characters from each line as specific in list.
-f   select only these field on each line.
-s   do not print lines not containing delimiters