Sie sind auf Seite 1von 2

File Content Search Command :-

à We can use find comm. To search for filenames in a directory

à To search for a pattern in one or more files,

Use the grep series of command.

à The grep comms. Search for a string within the specified fiels & display
the o/p on std. O/p.

grep :-

can be used to search for a specified pattern in one or more files ;

it displays the matching o/p on std. O/p.

 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 :-

1 grep dummy file1


2 grep –i -n dummy file1 à relative line number
3 grep -i -c dummy file1 à 2( just no of lines found )
4 if you want to get a list of all lines that do not contain the
specified pattern, use the –r flag grep –i –v dummy file1
script :-

from a file displays line that are not command.

5 If you want to find out which lines start with a capital letter A through C
,
Grep “^[A-C]” file1 ( ^ = Caret)

“^[^A-C]” (lines do not start with A


through C )

Strings :- Can be used to search for strings in executable files

Flag

-a or - à search the entire file, not just the data section.

-o à List each string preceded by its offset in the file ( in local )

-Number à Specify a min. string length other than the def. Of 4.

Printing :-

Cancel à cancel 734

lp à

pr à

lpstart à

Das könnte Ihnen auch gefallen