Search code examples
bashaliasrm

`rm -f` asks for confirmation, when aliased as `rm -i`


I'm using this command to try and delete all Thumbs.db files in a very large folder. I thought -f should force deletion without asking for confirmation, but i'm still being prompted for "y" or "n" on every file.

find "megapacks" -name Thumbs.db -ok rm -f {} \;

I tried type rm to see if there was an alias and it responded with

rm is aliased to `rm -i'

I tried using /bin/rm instead but i'm still being prompted

find "megapacks" -name Thumbs.db -ok /bin/rm -f {} \;

Does anyone have another idea for how to avoid the confirmation?


Solution

  • Problem is with -ok option that is as per man find:

    Like -exec but ask the user first. If the user agrees, run the command. Otherwise just return false.

    This should work for you with -exec:

    find "megapacks" -name Thumbs.db -exec /bin/rm -f {} \;
    

    or faster:

    find "megapacks" -name Thumbs.db -exec /bin/rm -f {} +