find

To find file(s). Major tip: a command can be executed for each of them.

Examples:

Prompt> find your-directory -name \*.html -exec grep 'searched_key' {} \;
Starting from "your-directory", this finds files recursively, looking for (grep) "searched_key" inside files whose name ends with ".html".
Prompt> find . -name \*.html -exec cp {} . \;
Starting from current directory, this copies (cp) recursively the files whose name ends with ".html" in the current directory.
Prompt> find . -name \*.html -exec sed -i 's/searched_key/new_key/g' {} \;
Starting from current directory, this modifies files recursively, replacing (sed) "searched_key" by "new_key" inside files whose name ends with ".html".

Nota bene:
{} means: for each file found.
The backslashes before "*" and ";" are required, in order to avoid their prior interpretation by the shell. Tip: quotes also work.
Tip: Just to find files, consider locate, which is quicker.



2014-11-06