bash - Unix 找到 : multiple -o and exec not working together

标签 bash unix 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/ \;

但是当我删除 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/

相关文章:

android - mipsel-linux-gcc : Command not found

linux - 提取斜线之间的文本 block

python - numpy loadtxt 跳过第一行

linux - 子进程是否复制整个数组?

linux - 用于检查在 x 分钟内没有创建文件的查找命令

linux - 从 makefile 访问 bash 特殊变量

xml - Unix : WildCard SubString Search between XML Tags

unix - ##*/在 UNIX Shell 脚本中使用

javascript - JS : Handle with find() property undefined

c++ - 为什么此代码在找到后不突出显示搜索词?