Using the Grep command
- Find all the txt files in the current directory
$ ls -1 | grep *.txt
- Find the text “CustomerID” in an XML file
$ grep CustomerID sample.XML
- Find all the ‘git’ commands in your history
$ history | grep git
- Highlight matched patterns
$ grep --color 'data' filename
- Ignore the case when searching for data
$ grep -i 'Data' filename
- Using Perl style Regular Expressions
$ grep -P "[\d]*" filename
This is a living document as work and personal projects require different ways to use Grep and other Linux commands.