下面这个find
命令列出当前目录下的*.stp
文件:
# find . -name '*.stp' -exec ls {} \;
./Documents/one.stp
./Documents/two.stp
关于find
命令的“-exec COMMAND \;
”:
find
-exec COMMAND \;
Carries out COMMAND on each file that find matches. The command sequence terminates with ; (the “;” is escaped to make certain the shell passes it to find literally, without interpreting it as a special character).
If COMMAND contains {}, then find substitutes the full path name of the selected file for “{}”.
;
的作用是标示命令完结,\;
是让shell
把;
原封不动地传给find
命令。而{}
会使用查找出来的文件的全路径名。
参考资料:
16.2. Complex Commands。