我今天得到了一个命令的帮助,但它似乎没有工作。命令如下:

find /home/me/download/ -type f -name "*.rm" -exec ffmpeg -i {} -sameq {}.mp3 && rm {}\;

shell返回

find: missing argument to `-exec'

我基本上要做的是递归地遍历一个目录(如果它有其他目录),并在.rm文件类型上运行ffmpeg命令,并将它们转换为.mp3文件类型。完成此操作后,删除刚刚转换的.rm文件。


当前回答

如果您仍然得到“find: missing argument to -exec”,请尝试将execute参数括在引号中。

find <file path> -type f -exec "chmod 664 {} \;"

其他回答

同样,如果其他人有"find: missing argument to -exec",这可能会有所帮助:

在某些shell中,您不需要进行转义,即您不需要在“;”前面加上“\”。

find <file path> -name "myFile.*" -exec rm - f {} ;

{}和&&都将由于被命令行展开而导致问题。我建议尝试:

find /home/me/download/ -type f -name "*.rm" -exec ffmpeg -i \{} -sameq \{}.mp3 \; -exec rm \{} \;

我觉得你得逃跑。

find /home/me/download/ -type f -name "*.rm" -exec ffmpeg -i {} \-sameq {}.mp3 \&\& rm {}\;

如果您仍然得到“find: missing argument to -exec”,请尝试将execute参数括在引号中。

find <file path> -type f -exec "chmod 664 {} \;"

为了防止有人在Amazon Opsworks Chef bash脚本中看到类似的“missing -exec args”,我需要添加另一个反斜杠来转义\;

bash 'remove_wars' do
  user 'ubuntu'
  cwd '/'
  code <<-EOH
    find /home/ubuntu/wars -type f -name "*.war" -exec rm {} \\;
  EOH
  ignore_failure true
end