nimrag nimrag - 7 months ago 62
Bash Question

Move directories less than 1G

I am trying to move all directories less than 1GB. I am trying to use this command:

du -h -d 1 -t -1G | xargs -0 mv -it /destination/dir/

But I get an error message:

mv: cannot stat [...] File name too long

Help would be greatly appreciated :)


So here is a workaround that serves my needs. Perhaps somebody can expand on it? Anyway, IF you don't need to worry about sub directories then the following works.

du -Sb -t -1G | cut -f 2- | xargs -d "\n" mv -t /path/to/destination/