user3052324 user3052324 - 7 months ago 19
Bash Question

Retain Directory Structure on exec within find application

Trying to move files and folders from one directory to another on linux shell. The below command is working for me but its not re-creating the directory structure. Hope someone can help.

find /var/spool/asterisk/monitor -iname ".wav" ! -name "-in.wav" ! -name "*-out.wav" -mtime +11 -exec cp {} /mnt/nfs/recordings/monitor \;

Note: within the monitor folder there are various folders and sub folders.


Use --parents in cp

find /var/spool/asterisk/monitor -iname ".wav" ! -name "-in.wav" ! -name "*-out.wav" -mtime +11 -exec cp --parents {} /mnt/nfs/recordings/monitor \;