Regular Expressions
The options can be as follows:
-i Ignore upper/lower case distinction in during comparisons.
-n Precede each line through its line number in the file (first line is 1).
-c Print only a count of the lines which contain the pattern.
-l Print only the names of files with matching lines, separated through NEWLINE characters. Don't repeat the names of files when the pattern is found more than once.
-v Print all lines except those which contain the pattern.
Let consider the file stud_rec with the following data
# cat stud_rec
Anjana 23 UC++ Annanagar
Divya 19 UC++ Padi
Farida 26 DBA T.Nagar
Prashant 22 UNIX Admin
Kilpauk Rahul 21 ORVB Shenoy Nagar
Fardeen 27 DBA Adayar
The students who are taking UCC++ course can be shown by using the grep as follows:
# grep UC++ stud_rec
Anjana 23 UC++ Annanagar
Divya 19 UC++ Padi