Search File
grep (global regular expression)
To search for specific words or patterns withing a the grep command is used. For example type
% grep studying mystuff.txt
Every line that contains the word "studying" is printed on the screen. Try doing this.
% grep STUDYING mystuff.txt
The grep command is case sensitive meaning it distinguishes between STUDYING and studying. To ignore being case sensitive the grep command must be used along with an option i.
% grep -i STUDYING studying.txt
Some of the other options of grep are:
- -v display those lines that do NOT match
- -n precede each matching line with the line number
- -c print only the total count of matched lines