user3052324 user3052324 - 1 year ago 81
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.

Answer Source

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 \;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download