Professional Documents
Culture Documents
à The grep comms. Search for a string within the specified fiels & display
the o/p on std. O/p.
grep :-
Flags
o -b display the block no. at the start of each line found.
o -c display the count of lines in which the pattern was
found without displaying the lines.
o -E behaves as egrep
o -F behaves as fgrep.
o -f filenamespecify filename that contains the patterns to be
matched.
o -h suppress the filenames as part of the display,
if more than one file is being searched.
o -i search, ignoring the case of the letter.
o -l list just the filenames in which the speci. Pattern
has been found.
o -n display relative line no. before each line in o/p
o -Q suppress all o/p
o -V Find lines not matching the specified pattern.
o -W search for specified patterns as words.
o -X Match the patterns exactly with a line.
Ex :-
5 If you want to find out which lines start with a capital letter A through C
,
Grep “^[A-C]” file1 ( ^ = Caret)
Flag
Printing :-
lp à
pr à
lpstart à