find: missing argument to -exec (remove Picasa.ini files) Nov 19 2004

So let’s say you just ran Picasa, Google’s new aquisition, and it displays all your pictures great. It’s actually a reall neat little application, pretty slick.

However, it is not so slick that it can’t help but leave a (hidden) “Picasa.ini” file in every directory it finds images in. That is mostly fine, except for how it also indexes everything, including directories under source control (CVS).

So, whipping out trusty cygwin (could also do it using Explorer Search feature…), I try $ find . -name "Picasa.ini" -exec rm {}/;

Results without the space:

$ find . -name "Picasa.ini" -exec rm {}/;
find: missing argument to '-exec'

Frustrating.

Solution:
You MUST include a space between the {} and the /;. If you don’t you will get the missing argument error. If you put the space in, you will successfully delete every Picasa .ini file.

$ find . -name "Picasa.ini" -exec rm {} /;

Bonus:

From j0hnny

Picasa is an ‘Automated Digital Photo Organizer’ recently aquired by Google. This search allows the voyer to browse directories of photos uploaded using the picasa software.


SOME ADVERTISEMENTS THAT MIGHT BE RELATED TO THIS CONTENT


8 Responses to “find: missing argument to -exec (remove Picasa.ini files)”

  1. Sunith Dodda Says:

    Hi,
    as you suggested, i tried like this writing in a “Delete.sh” file.
    –>To delete directories older than 2 days in /sunith/sub1/*

    #!/bin/bash
    $ find /sunith/sub1/* -type d -mtime +2-exec rm -rf {} \;

    when runned i get the following problem:
    find: missing argument to `-exec’
    can you resolve this for me
    Thanks and Regards,
    Sunith

  2. Gabriel Says:

    Sunith,

    It looks like you’re trying to delete ALL directories older than 2 days that are contained in /sunith/sub1/. Is that correct?

    If that’s what you want to do, I would suggest the following fix to your command:

    Inside your Delete.sh file:

    #!/bin/bash
    find /sunith/sub1/* -type d -mtime +2 -exec rm -rf {} \;

    Key things to look for:

    – Make sure that in your bash shell script you don’t put in the $ in front of the find command.

    – Make sure that there is a space before the -exec flag (it looks like in your comment that there isn’t one).

    – Make sure you have a space before the final escaped semicolon. Also keep in mind that on Windows systems (running Cygwin) the escape character is a / (forward slash), and on Unix type systems the escape character is a \ (back slash).

    I hope this helps.

  3. Sunith Dodda Says:

    Hi,
    I tried writing this way in my bash shell script:(Delete.sh)

    #!/bin/bash
    find /sunith/sub1/* -depth -type d -mtime +2 -exec rm -rf {} \;

    But i am here with the same problem.
    when runned i get the following problem:
    find: missing argument to `-exec’
    can you resolve this for me

    Thanks and Regards,
    Sunith

  4. Gabriel Says:

    Sunith,

    What do you get when you run just this command from the command line?

    find /sunith/sub1/* -depth -type d -mtime +2

  5. Sunith Dodda Says:

    hi,
    thank you,
    when i run at command line:
    $find /sunith/sub1/* -depth -type d -mtime +2
    the results are fine, i.e, I can see the sub folders in /sunith/sub1/ which are older than 2 days.
    But when i put the same command i am not getting the results till morning.
    Now it is working fine in my bash scripting file.
    But why was that happen for the last time, and with out changing any thing it is performing fine. how is that…
    will be there any malfunctioning of bash..
    Thanks and Regards,
    Sunith

  6. Dan D. Says:

    This was just what I was looking for. Thanks!

  7. Cruzo Says:

    I have a same problem:

    When I executed this line:
    find /archive/expfiles/archivelogs -type f -mtime +13 -exec rm {} ;
    on the command line, it works fine
    but when I placed it in a bash script file and tried executing the script, it gives error:
    find: missing argument to '-exec'

    I have not been able to resolve this for the last couple of months now so I really need some gurus out there to point to me why my find command could not run as a script.

    Cruzo

  8. Emil Says:

    I guess you are missing a backslash before the semicolon in the end of line. Why don’t you try with

    find /archive/expfiles/archivelogs -type f -mtime +13 -exec rm {} /;

    Cheers,
    Emil

Leave a Reply



sell diamonds