Vin*_*ino 5 unix bash find osx-mavericks
当我运行以下命令时,尽管 find 命令显示结果,但没有移动任何文件。
find "/Users/Vino/Media/test" -type f -size +100M \
-name *.mkv -o -name *.mp4 -o -name *.avi \
-exec mv {} /Users/Vino/Media/ \;
Run Code Online (Sandbox Code Playgroud)
但是当我删除or.avi 和 .mp4 的运算符时,它会执行其预期的操作
find "/Users/Vino/Media/test" -type f -size +100M \
-name *.mkv -exec mv {} /Users/Vino/Media/ \;
Run Code Online (Sandbox Code Playgroud)
这有点令人费解,因为这是一个相当简单的命令,我曾经在 OS X 10.6 下运行过。我现在使用的是 OS X 10.9。
将我的评论变成答案。
您必须明确哪些find是 的操作数-o。您可以通过分组来做到这一点():
find "/Users/Vino/Media/test" -type f -size +100M \
\( -name *.mkv -o -name *.mp4 -o -name *.avi \) \
-exec mv {} /Users/Vino/Media/ \;
Run Code Online (Sandbox Code Playgroud)
从手册页:
( expr )
Force precedence. Since parentheses are special to the shell,
you will normally need to quote them. Many of the examples in
this manual page use backslashes for this purpose: `\(...\)'
instead of `(...)'.
Run Code Online (Sandbox Code Playgroud)