YamdaBlam!

When ‘mv’ fails you

by Jay on Jun.02, 2010, under Technology

Very handy linux command I keep forgetting so here it is:

Scenario:

You need to move a few thousand files from one directory to another on a linux server. The mv command gives the following complaint:

“Argument list too long…”

You can use this bad boy (assuming you are in the directory containing the files you want move):

find . -type f -name ‘*’ -exec mv {} $newdir/. \;

Wait a few seconds and list the contents of the directory to see that its now empty. Check the contents of your $newdir to see if the files have moved.

:, , , ,
No comments for this entry yet...

Leave a Reply

Powered by WP Hashcash

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

 

Archives

All entries, chronologically...