BASH Script for copying files recursively form one directory to another

#!/bin/bash
 
# Author : Antony
# Date   : 19/07/2008
# Description : Script for copying files recursively form one directory to another
 
# Get Source and Destination Directory Paths
echo "Enter the source path"
read src
echo  "Enter the Destination path"
read dest
 
for file in `find $src -name "*.*"`
do
echo $file
echo `cp $file $dest`
done

No Responses to “BASH Script for copying files recursively form one directory to another”

  1. Jyoti Sharma says:

    cp -R src dest

    will achieve the same thing much more elegantly.

    Regards.

  2. admin says:

    Yes you are right .. But this program is just an example for loop in bash . .

    #!/bin/bash
    
    # Author : Antony
    # Date   : 19/07/2008
    # Description : Script for copying files recursively form one directory to another
    
    # Get Source and Destination Directory Paths
    echo "Enter the source path"
    read src
    echo  "Enter the Destination path"
    read dest
    cp -rf src dest
    done
    

Leave a Response