Professional Documents
Culture Documents
CM
CM
CM
Name Designation Branch Institute Year/Semester Subject Subject Code Topic Duration Sub Topic Teacher Aids : : : : : : : : : : : A V N L Sarojini Lecturer Computer Engineering A.A.N.M. & V.V.R.S.R. Poly., Gudlavalleru. III Semester UNIX & C CM-304 Shell Programming & Filtering Techniques 50 Min Usage of grep PPT
CM304.22
Objective
On completion of this period you would be able to know
grep command grep command options Searching for a pattern using grep command Introduction to Regular expression.
CM304.22
Recap
UNIX provides sort command to sort the contents of
a file.
standard output in a file, as well as display it on the terminal (or pipe into a another command) this is made possible by the tee command.
CM304.22 3
CM304.22
CM304.22
CM304.22
When the pattern consists of more than one word, then it must be enclosed in single (or) double quotes. $grep Rama Rao emp.1st
CM304.22
CM304.22
10
CM304.22
11
CM304.22
12
CM304.22
13
CM304.22
14
CM304.22
15
Regular Expression
A regular expression is a string of ordinary and
metacharacters which can be used to match more than one type of pattern.
CM304.22
16
Regular Expression
Regular expression used by grep command are Expression ch * Meaning Matches zero or more occurrences of the previous character ch
.
[pqr]
Regular Expression
Regular expression used by grep command are Expression [^pqr] ptn $ ^ ptn Meaning Matches single character which is not p, q (or) r. Matches the pattern ptn at the end of the line. Matches the pattern ptn at the beginning of the line.
CM304.22 18
Summary
The grep command is useful in look for a pattern in a
file.
pattern in its input file and by default outputs the lines containing the pattern.
19
Summary
Most of the grep options are shared by its other
members also (egrep and fgrep).
20
Quiz
1.When the pattern consists of more than one word, then it must be enclosed in single (or) double quotes. [TRUE / FALSE]
CM304.22
21
Quiz
1.When the pattern consists of more than one word, then it must be enclosed in single (or) double quotes. [TRUE / FALSE]
CM304.22
22
Quiz
2. Grep command is case sensitive when searching for a pattern in file [TRUE / FALSE]
CM304.22
23
Quiz
2. Grep command is case sensitive when searching for a pattern in file [TRUE / FALSE]
CM304.22
24
Quiz
3.While constructing regular expression we can use * to match a single character. [TRUE / FALSE]
CM304.22
25
Quiz
3.While constructing regular expression we can use * to match a single character. [TRUE / FALSE]
CM304.22
26
CM304.22
27