I want to copy all the files newer than another one from their original location /lib/
into another destination /dest/lib/
To identify these files I simply use:
$ cd /lib/
$ find . -newer foobar
./foo/bar.py
./bar/foo/bar/foo.py
...
Unfortunately I cannot simply use this command because cp
does not know how to create folders on the fly.
So I used this command:
find /foo -type f -newer foobar | \
xargs -n1 -I% sh -c 'mkdir -vp `dirname /dest/%` && cp -v % /dest/%'
This looks very complicated and is incredibly slow. Is there a better solution?