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.