0

I am trying to copy the files from source to Target folder which has been modified between 2 dates,

#!/usr/bin/ksh

source=/home/Amal/DELTA/SOURCE

target=/home/Amal/DELTA/TARGET

cd $source

find ./ -type f -newermt "2021-07-08 00:00:00" ! -newermt "2021-09-18 23:59:55" -printf "%h:%p:\0" |

while IFS=":" read path file; do

cp "$file" "$target"/"$path"

done

NOTE: Source and directory is having same directory structure already. I just need to copy the files as same as SOURCE directory.

When i execute this script no changes in TARGET folder.

N0rbert
  • 103,263
Amala
  • 1

1 Answers1

0

One way could be to use rsync with the --include-from-file option. rsync is a versatile file copy utility that will by default copy directory structures. With the --include-from-file option, you can point rsync to a list, a text file, that determines the files that should be included in the copy. Such list can be created with the find command.

So first run the find to locate the desired files and list them in a text file. Then use rsync to only copy these files over. Easy to script once you got it working, obviously.

vanadium
  • 97,564