Argument list too long

After run rm -f * you get the error /bin/rm: Argument list too long

Possible options:

Use xargs. Xargs pass a list of arguments to a command. This deletes all the files listed:

ls |xargs rm

Use find. You can use the find command to make some actions with the found elements.

find . -exec rm {} \;

If you don´t remember any of the above options, always can remove the whole directory and create it again. Caution with the subfolders!

This entry was posted in Linux and tagged , . Bookmark the permalink.

One Response to Argument list too long

  1. Alberto de Tena says:

    I’ll teach you another way that I use quite a lot for doing stuff like this.

    for file in `ls`; do
    rm -f $file
    done

Deja un comentario