Execute a command on the results of a search with the find command 1


find $LOCATION -name "$FILENAME" -exec somecommand '{}' \;

The above command will search in $LOCATION for all files named $FILENAME and apply the command that you define at somecommand.

The argument ‘{}’ inserts each file found into the somecommand syntax. The \; argument indicates the exec command line has ended — YOU MUST INCLUDE IT.

This post is also available in: Greek


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

One thought on “Execute a command on the results of a search with the find command