list all files in directory tree that contain a search string
find . -type f -print | xargs grep -li "find me"If you have a large directory tree and you are sure that a file is in there somewhere, and you know that the phrase "find me" (e.g.) is in what you are looking for, then a command line like the above is just what you need.
The find command filters out all directories and special files and prints a list of them to the pipe. The xargs command takes the piped list and makes it into an argument list for the grep. The -li options on the grep mean ignore case...so "FIND ME" or "find me" is matched, and list once means the output is a list of filenames which only mentions each file once.
- 1Linux Top 3: Alpine Linux 3.4, deepin 15.2 and Linux Lite 3.0
- 2Linux 4.7 Set to Boost Live Patching, Security and Power Management
- 3Linux 4.6 Charred Weasel adds USB 3.1 Support
- 4Linux Top 3: OpenIndiana 2016.04, Ubuntu 16.04 and Debian's New Leader
- 5Linux Top 3: KaOS 2016.04, TurnKey 14.1 and pfSense 2.3