November 1, 2007

Argument list too long – xargs is the solution…

Filed under: Linux, Systems Administration, Uncategorized — kenjun @ 3:55 pm

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


1 Comment »

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

    Comment by girlgeek — August 3, 2008 @ 7:39 pm

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: