This shell script is designed for a specific task required for our server. So sharing the script with Tecadmin readers. It might be helpful for you.

Requirement

Our requirement is to copy all files created in directory to other directory with same directory structure. Script will run on a regular interval, search for all files created in source directory and copy them to destination directory. The script must maintain the same directory structure on destination directory. After that change the permission on destination directory. After successful copy of file, script must remove the file from source directory.

Shell Script

Create a shell script on your system and add below content. Update source and destination directories to proper location.

Set CHANGE_OWNERSHIP to 0, if you don’t want to change ownership on destination files.

#bash shell #bash #shell script

A Shell Script to Copy All files with Same Structure
1.10 GEEK