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!


COMENTARIOS / UN COMENTARIO

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

Alberto de Tena 11 Apr 2008 a las 1:54 pm

COMENTA

Tags disponibles: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Return to Top