Example 1: To find all instances of "error"
$ grep error /var/log/messages
Example 2: To find all instances of "error", regardless of capitalisation, or case-insensitive, use the flag "-i"
$ grep -i error /var/log/messages
Example 3: Resursive check, use the "-r" flag
$ grep -ri /var/log/messages
Example 4: Colour your output with --color=auto
$ grep -ri --color=auto error /var/log/messages
Example 5: Whole word matching with "-w" flag
$ grep -riw error /var/log/messages
Example 6: Count the number of matches
$ grep -riwc error /var/log/messages
Example 7: To search for more than 1 word, put a quote
$ grep -ri 'ACPI Error' /var/log/messages
Finally, need help?
$ grep --help $ man grep
1 comment:
Some examples on Find Command and Awk Command
Post a Comment