Search Inside Text Files With Grep

Grep is too important not to know for Linux sysadmins. Grep is commonly combined with other commands via pipes to search and filter standard output. In the examples below I show you how to search through text files on your system.

Parameter descriptions

-r – recursively search, not just the folder you’re in now

‘bitbook’ searches for the case sensitive string ‘bitbook’, without quotes

* – file mask for match all

Examples

Search through all text files from current directory and down for bitbook.

grep -r 'bitbook' *

Search through all csv files from current directory and down for bitbook.

grep -r 'bitbook' *.csv

Search through all txt files only in current directory for bitbook ignoring case.

grep -i 'bitbook' *.txt