Codeschnipsel BASH – for-Schleife mit Text-Array

#!/bin/bash

# rsync old nas shares to the new ones
#       /old_dir1/         /new_dir1/
#       /old_dir2/subdir/  /new_dir2/subdir/
#       /old_dir3/         /new_dir3/
#       /old_dir4/         /new_dir4/

### vars
startDate=$(date)
declare -a sourceDir=("/old_dir1/" "/old_dir2/subdir/" "/old_dir3/" "/old_dir4/")
declare -a targetDir=("/new_dir1/" "/new_dir2/subdir/" "/new_dir3/" "/new_dir4/")
rsyncOptions=" --recursive --ignore-existing --human-readable --progress --owner --group --times --links"

### sync mounts
for ((i=0; i < ${#sourceDir[@]}; i++))
do
        #echo "rsync ${rsyncOptions} ${sourceDir[$i]} ${targetDir[$i]}"
        rsync ${rsyncOptions} ${sourceDir} ${targetDir}
done

finishDate=$(date)
printf "all finished and rsynced!\nStart Time:  ${startDate}\nFinish Time: ${finishDate}\n\n"

exit 0