UNIX FILTERS



grep                           Search a file for a matching pattern or regular expression.
Usage: grep [options] <regular-expression> <file-name>
Options: -n print lines and line numbers
-v prints all the lines that do not contain the expression.
Eg: grep [a-z]*.C filename
grep *[SITE]* filename

fgrep                         A variation of grep that maches a text-string and does-not
support regular expressions.
Eg: fgrep <string> <file-name>

spell                          Exercise >> to be completed by students

sort                            Exercise >> to be completed by students

head                          Exercise >> to be completed by students

tail                             Exercise >> to be completed by students

find                            Search the system for filenames.
Usage: find <pathname> <condition>
Eg: find /home/hoda -name seed

split                           Splits a file into several files of equal length.
Usage: split [options] <filename> <outfile>.
Options: -n specifies the number of lines per file.
Another variation of split is csplit which splits the file using a specified expression as a splitting point.

cmp                           Compare 2 files.
Usage: cmp <file1> <file2>

diff                             Reports the lines that differ between 2 files
Usage: diff <file> <file2>

join                            A database operator that joins the common lines of two sorted  files.
Usage: join <file1> <file2>

Previous                                                                                                       

No comments:

Post a Comment

Copyright © EduRAR @ www.edurar.blogspot.in