How to , and other stuff about linux, photo, php … A linux, photography blog. To remember some linux situation, and fix them quickly.

March 31, 2008

/bin/rm: Argument list too long

Filed under: Linux — admin @ 2:23 pm

If you try to remove some file and recive that error. Then one solution is to combine find with xargs.

find . -name ‘spam-*’ | xargs rm

This will send one line to the rm command.

If the filenames involved have spaces, you will need to do use find’s
“-print0” option in conjunction with xargs’s “-0” option. otherwise the
shell that xargs uses to execute the “rm” command line will treat the
space as a token separator, thereby treating the name as two (or more)
names, none of which are the thing you’re trying to actually delete.
the command line should look like this…

find . -name ‘spam-*’ -print0 | xargs -0 rm

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress