


-i : Ignore case distinctions in patterns and data.

r -w -n 'regex' /dir / Understanding grep command options that used for searching text files Want to search files having either ‘.pl’ or ‘.php’ extensions for foo()? Try:
#Search for text in files mac os how to
Grep -r -E 'orange|mango' /dir/to/search/įor extended grep (see egrep command for regular expressions):Įgrep -rnw 'regex' /path/to/search/ How to search only files that have specific extensions Say you want to find orange and mango words, then try: Grep -r -l "foo" /path/to/dir/*.c Using find command to search recursivelyįind command is recommend because of speed and ability to deal with filenames that contain spaces.įig.01: Unix and Linux: How to Grep Recursively? Finding all files containing specific text on Linux To display print only the filenames with GNU grep, enter: Displaying files name when searching for a string/word Grep -R 'string-to-search' /path/to/dir/ Case sensitive recursive search Follow all symbolic links too by passing the -R (capital R): The following syntax will read and search all files under each directory, recursively. Grep -r 'something' /path/to/dir Following symtlinks In other words, it will look into sub-directories too. The -r option read/sarch all files under each directory, recursively, following symbolic links only if they are on the command line. The syntax is as follows for the grep command to find all files under Linux or Unix in the current directory: How to use grep command to recursively search All files for a String
