Grep command is use to search for a patterns in the files. The patterns can be defined by the user and can be of various types. The standard input device in Linux is Keyboard and standard output device is Monitor. Grep command accepts the input from the files user specify or from the standard input device i.e keyboard. To illustrate the grep I have created the three files: ex1, ex2 and ex3.
1. Searching string in the file:
grep word(s) filename
2. Searching except particular string:
grep -v word(s) filename
3. Displaying certain strings from all the files:
grep -n word(s) *
4. Displaying Both Upper and Lowercase: Linux command is case sensitive so the grep command is.
grep -i word(s) *
5. Display number of lines that contains text:
grep -c word(s) *
6. Display with line numbers:
grep -n '^' ex3
7. Display using wildcards:
You can more information about grep command in the manual page.