0% found this document useful (0 votes)
45 views

Scripting Language Lab 2

The document describes an experiment aimed at learning various filter commands in the Linux operating system. It lists and provides brief explanations of common Linux commands like grep, cat, comm, diff, find, sort, tail, head, cut, paste, uniq, tr, sed, and tee; and provides examples of using each command to filter, compare, edit, and manipulate file contents.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Scripting Language Lab 2

The document describes an experiment aimed at learning various filter commands in the Linux operating system. It lists and provides brief explanations of common Linux commands like grep, cat, comm, diff, find, sort, tail, head, cut, paste, uniq, tr, sed, and tee; and provides examples of using each command to filter, compare, edit, and manipulate file contents.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

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 > test2.txt add contents


• cat > test3.txt add contents

• comm: compare two sorted files line by line and


write to standard output

• Diff : diff test2.txt test3.txt


a - Add the lines., c - Change the lines., d - Delete the
lines
• Find . -name test2.txt : it searches test2.txt 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 text3.txt
• Tail -3 text3.txt : displays the last three lines
• Tail +2 text3.txt : moves tail part up by 2

• head test2.txt
• head test2.txt : displays 10 lines from head part of the file
• head -3 test2.txt : displays first 5 lines from head part of
file
• Cut -c2-2 test2.txt : 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 test2.txt | tee test9.txt : displays the content in
reverse order by creating a new file test9.txt

You might also like