在linux 里man find 里有一段说明:
-exec command ;
Execute command; true if 0 status is returned. All following
arguments to find are taken to be arguments to the command until
an argument consisting of `;' is encountered. The string `{}'
is replaced by the current file name being processed everywhere
it occurs in the arguments to the command, not just in arguments
where it is alone, as in some versions of find. Both of these
constructions might need to be escaped (with a `\') or quoted to
protect them from expansion by the shell. The command is exe-
cuted in the starting directory.
意思是说可以在FIND后调用外部命令,不过,由于英语难懂,一时很难理解。且没EXAMPLE,试验后如下:
find . -name "*.jsp" -exec grep 192.168.80.197 {} -H \;
这条命令的意思是,查当前目录以下包括各个子目录中所有jsp文件,并用GREP查代里面含有“192.168.80.197”字样,并把这个文件名显示出来。
另外,要注意的是,在使用时,经常遇到 find: missing argument to `-exec'
这个意思并不是说没有exec参数,而是exec后面的参数不对。这时,应该检查\;之前有没有空格之类