Argument list too long – xargs is the solution…

If you’re dealing with a lot of files and get messages like:

mv *.* tmp/
-bash: /bin/mv: Argument list too long

then you need xargs. For example,

Moving Files: 

To move vast number of files from /a/b to /c/d do:

ls . | xargs -i mv /a/b/{} /c/d/{}

The -i argument to xargs says fill in all the {} expressions on the right hand side of the pipe with all the values being generated on the left hand side of the pipe. Or use:

find . -name “thisname-*” | xargs -i mv {} thisname/{}

 Deleting Files

find . -type f -name “*” -print|xargs rm


One thought on “Argument list too long – xargs is the solution…

  1. girlgeek says:

    Thank you. I had been having this problem. Good to learn this info.

Leave a Reply

Your email address will not be published. Required fields are marked *