I have the following command:
find . -type d -mtime 0 -exec mv {} /path/to/target-dir \\;
This will move the directory founded to another
find ./ -maxdepth 1 -name "some-dir" -type d -print0 | xargs -0r mv -t x/
find:
with option -print0
, the output will end with '\0';
xargs:
with option -0
, it will split args by '\0' but whitespace, -r
means no-run-if-empty, so you will not get any errors if find
didn't get any output. (The -r
is a GNU extension.)
I usually use this in scripts when I'm not sure if the target files exist or not.