- Search for file with a specific name in a set of files:
This command will search in the current directory and all sub directories for a file named soap_fault_text.c.
find . -name "soap_fault_text.c" -print
- Applying a Linux command to a set of file (-exec):
This command will search in the current directory and all sub directories. All files named soap_fault_text.c will be processed by the chmod -o+r command. The argument '{}' inserts each found file into the chmod command line. The \; argument indicates the exec command line has ended.
find . -name "soap_fault_text.c" -exec chmod o+r '{}' \;
- Search for a string in a selection of files (-exec grep ...):
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.
find . -exec grep "www.athabasca" '{}' \; -print
Using ‘find’ command in Linux
May 21st, 2008 · No Comments · linux tips
The find command allows the Linux users to process a set of files and/or directories in a file subtree.Users can specify where to search, what type of file to search for (-type: directories, data files, links), how to process the files (-exec: run a process against a selected file), the name of the file(s) (-name) and perform logical operations on selections (-o and -a).
Here are some examples:


