Scripting Language Lab
Experiment 2
Debdatta Praharaj
21MVD1027
AIM: To learn the filter commands
in the Linux operating system.
• Grep : The grep filter searches a
file for a particular pattern of
characters, and displays all lines
that contain that pattern
• Cat > [Link] add contents
• cat > [Link] add contents
• comm: compare two sorted files line by line and
write to standard output
• Diff : diff [Link] [Link]
a - Add the lines., c - Change the lines., d - Delete the
lines
• Find . -name [Link] : it searches [Link] in scripts
directory
• Find . name *.txt It will give all files which have ‘.txt’
at the end.
• Find . -size +1000c ##searches and displays files with size
greater than 1000bytes.
• Find . -atime -l : searches and displays all files which were
accessed in less than a day.
• Find . -mtime +1 : searches and displays all the files which
were modified 1 day ago.
•
• Sort : sort command sorts the contents of a file, in
numeric or alphabetic order, and prints the results to
standard output.
• Tail [Link]
• Tail -3 [Link] : displays the last three lines
• Tail +2 [Link] : moves tail part up by 2
• head [Link]
• head [Link] : displays 10 lines from head part of the file
• head -3 [Link] : displays first 5 lines from head part of
file
• Cut -c2-2 [Link] : cuts the characters before 2 nd
position and after 5 th position of content of file
• Paste –d: uses a single delimiter to separate contents of
different files.
• Paste -s : displays contents of each file in each column
separated by a space.
• Uniq: searches the data and filters the data by eliminating
duplicate content present in file.
• Tr : used to transform the data in the specified file
•
• Sed: stream editor. Used to edit (searching, find and
replace, insertion, deletion) the data.
• Tee : Takes the content from one file and writes output to
multiple files.
• Tac [Link] | tee [Link] : displays the content in
reverse order by creating a new file [Link]