find: missing argument to -exec

后端 未结 11 2125
心在旅途
心在旅途 2020-11-28 17:52

I was helped out today with a command, but it doesn\'t seem to be working. This is the command:

find /home/me/download/ -type f -name \"*.rm\" -exec ffmpeg -         


        
相关标签:
11条回答
  • 2020-11-28 18:08

    You need to do some escaping I think.

    find /home/me/download/ -type f -name "*.rm" -exec ffmpeg -i {} \-sameq {}.mp3 \&\& rm {}\;
    
    0 讨论(0)
  • 2020-11-28 18:10

    Just in case anyone sees a similar "missing -exec args" in Amazon Opsworks Chef bash scripts, I needed to add another backslash to escape the \;

    bash 'remove_wars' do
      user 'ubuntu'
      cwd '/'
      code <<-EOH
        find /home/ubuntu/wars -type f -name "*.war" -exec rm {} \\;
      EOH
      ignore_failure true
    end
    
    0 讨论(0)
  • 2020-11-28 18:12

    Also, if anyone else has the "find: missing argument to -exec" this might help:

    In some shells you don't need to do the escaping, i.e. you don't need the "\" in front of the ";".

    find <file path> -name "myFile.*" -exec rm - f {} ;
    
    0 讨论(0)
  • 2020-11-28 18:18

    Both {} and && will cause problems due to being expanded by the command line. I would suggest trying:

    find /home/me/download/ -type f -name "*.rm" -exec ffmpeg -i \{} -sameq \{}.mp3 \; -exec rm \{} \;
    
    0 讨论(0)
  • 2020-11-28 18:22

    Just for your information:
    I have just tried using "find -exec" command on a Cygwin system (UNIX emulated on Windows), and there it seems that the backslash before the semicolon must be removed:
    find ./ -name "blabla" -exec wc -l {} ;

    0 讨论(0)
  • 2020-11-28 18:25

    I figured it out now. When you need to run two commands in exec in a find you need to actually have two separate execs. This finally worked for me.

    find . -type f -name "*.rm" -exec ffmpeg -i {} -sameq {}.mp3 \; -exec rm {} \;
    
    0 讨论(0)
提交回复
热议问题