Got a directory with > 10K of files? Need to move them up one directory? mv will fail you:
|
1 2 |
$ mv * .. -bash: /bin/mv: Argument list too long |
The solution is to list the files one line at a time (with find or ls -1) and feed that to xargs:
|
1 |
ls -1 | head -100 | xargs -I f mv f .. |
This moves the first 100 files up one directory.
Note that this won’t work if you’ve got whitespace in your filenames. Use find -0 and xargs -0 to null-separate your filenames in that case.