The article
14 Practical examples of the grep command
has some good examples on how to use the grep command.
The Perl style (option
-P) regular expression is more powerful than the basic (default) and extended (option-E) regular expression. It is suggested that you use the perl style as much as possible. However, be careful about unimplemented features.The option
-n/--line-numberprefixes each line of output with the 1-based line number within its input file. And the option-o/--only-matchingprints only the matched (non-empty) parts of a matching line, with each such part on a separate output line. Both of those options are very useful.Search in current directory recursively for files containing the text “video”. Symbolic links are followed.
:::bash grep -iR 'video' .Search in current directory recursively for files containing the text “video”. Symbolic links are NOT followed.
:::bash grep -ir 'video' .