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!

Esta entrada fue publicada en Linux y etiquetada , . Guarda el enlace permanente.

Una respuesta a Argument list too long

  1. Alberto de Tena dice:

    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

Tu dirección de correo electrónico no será publicada. Los campos necesarios están marcados *

*

Puedes usar las siguientes etiquetas y atributos HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>