Hey guys,
I just faced one those annoying errors today.
My script usually runs fine with the
mv /my/random/source_directory/* /my/random/dest_directory/
But today it failed.
And after some googling and trying out I figured out what worked and what didn't.
The first link that came on on google didn't help me at all.
There were around 24k files in that directory to move.
I got the first solution from here:
http://blog.supportpro.com/2011/04/how-to-fix-%E2%80%9Cbinmv-argument-list-too-long%E2%80%9D-error/
It says I could use find command and xargs and get the job done. But nope. It didn't work for me. I just kept getting the same Argument list too long error for find.
The command looked like below
find /path/to/file/* -type f | xargs -i mv “{}” /path/to/move
How I got it resolved was by sending batches of file using the same command above, by narrowing down my resultant list to mv.
But I could have done a lot of other stuff like:
I just faced one those annoying errors today.
My script usually runs fine with the
mv /my/random/source_directory/* /my/random/dest_directory/
But today it failed.
And after some googling and trying out I figured out what worked and what didn't.
The first link that came on on google didn't help me at all.
There were around 24k files in that directory to move.
I got the first solution from here:
http://blog.supportpro.com/2011/04/how-to-fix-%E2%80%9Cbinmv-argument-list-too-long%E2%80%9D-error/
It says I could use find command and xargs and get the job done. But nope. It didn't work for me. I just kept getting the same Argument list too long error for find.
The command looked like below
find /path/to/file/* -type f | xargs -i mv “{}” /path/to/move
How I got it resolved was by sending batches of file using the same command above, by narrowing down my resultant list to mv.
But I could have done a lot of other stuff like:
find $directory -type f -name '*' -exec mv {} $directory2/. \;
Which somehow seemed to work. Though it is a very slow command.
More stuff can be found here at LinuxJournal.
I hope that was useful
Comments
Post a Comment