www.delorie.com/gnu/docs/findutils/find_40.html   search  
 
Buy GNU books!


Finding Files

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3.1 Single File

Here is how to run a command on one file at a time.

Action: -exec command ;
Execute command; true if 0 status is returned. find takes all arguments after `-exec' to be part of the command until an argument consisting of `;' is reached. It replaces the string `{}' by the current file name being processed everywhere it occurs in the command. Both of these constructions need to be escaped (with a `\') or quoted to protect them from expansion by the shell. The command is executed in the directory in which find was run.

For example, to compare each C header file in the current directory with the file `/tmp/master':

 
find . -name '*.h' -exec diff -u '{}' /tmp/master ';'


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 2003   by The Free Software Foundation     Updated Jun 2003