Grep and egrep are tools that search for patterns in files and
find all lines containing a particular string.
Format:
grep RE filename
(see UNIX in a nutschell and man grep for more detailed description)
Examples:
grep "youruserid" marks
- prints all lines which contain 'youruserid' in the file 'marks'
grep "" classlist
- prints all lines which contain a character '
'.
grep "[Pp]roced.*" *.java
- prints all lines which contain Proced or proced in all files with extension java.
Note the significant difference between '' as used in RE and '
' used in shell.
Since shell may be easily confused by '
' or any other special character in
regular expression, it is always recommended to quote (by using '' or "") RE.