当我运行以下命令时,尽管 find 命令显示了结果,但没有移动任何文件。
find "/Users/Vino/Media/test" -type f -size +100M \
-name *.mkv -o -name *.mp4 -o -name *.avi \
-exec mv {} /Users/Vino/Media/ \;
但是当我删除
or
.avi 和 .mp4 的操作符find "/Users/Vino/Media/test" -type f -size +100M \
-name *.mkv -exec mv {} /Users/Vino/Media/ \;
这有点令人费解,因为它是一个相当简单的命令,我曾经在 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/ \;
来自 the man page :
( 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 `(...)'.
关于bash - Unix 找到 : multiple -o and exec not working together,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29162020/