格式:
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相似,但匹配时对大小写不敏感。