Dealing with a directory with ~∞ files

Got a directory with > 10K of files? Need to move them up one directory? mv will fail you:

The solution is to list the files one line at a time (with find or ls -1) and feed that to xargs:

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.

Tagged with:
Posted in Technical HOWTOs