I was trying to use the find command to find some files using an expression and create those particular directories in a destination folder and copy the respective files.
find /home -type f -mmin -60
The above prints some files on the terminal which have some files under nested directories and I want to create these additional directories under output/ in the same hierarchy structure
find /home -type f -mmin -60 -execdir sh -c 'mkdir -p 'output/$0' && cp "$1" "output/$0"' sh {} \;
This does not work at all and acts pretty weirdly
I would use install
command:
find /home -type f -mmin -60 -exec install -D -m644 {} output/{} \;
It transparently copy files and run mkdir
under the hood.