4th Floor, 4 Tabernacle Street London EC2A 4LU

Search String in Directory – UNIX

How to search for a string in a selection of files (-exec grep …).

[bash] find . -exec grep “searchstring” ‘{}’ \; -print
[/bash] [bash]

find . -exec grep “searchstring” ‘{}’ \; -ls

[/bash]

This command will search in the current directory and all sub directories. All files that contain the string will have their path printed to standard output.