格式:
find -iname "*.?" -exec 'command' {} \; //注意{ }和\;之間的空格。
find命令對匹配的文件執行該參數所給出的shell命令。
example:
find -iname "*.mp3" -exec mid3iconv -e gbk {} \;
找出當前文件及子文件夾下的所有mp3文件,用mid3iconv把所有音樂文件的是 GBK 編碼的標籤轉換爲 Unicode 編碼,解決使用Rhythmbox播放音樂時,音樂標籤顯示亂碼的問題。
PS--參數-iname與-name的區別:(man參考)
Like -name, but the match is case insensitive. For example, the
patterns `fo*' and `F??' match the file names `Foo', `FOO',
`foo', `fOo', etc. In these patterns, unlike filename expan‐
sion by the shell, an initial '.' can be matched by `*'. That
is, find -name *bar will match the file `.foobar'. Please note
that you should quote patterns as a matter of course, otherwise
the shell will expand any wildcard characters in them.
與-name相似,但匹配時對大小寫不敏感。