Is there a way to do the follow below?
#!/bin/bash -x
IPFILE_LIST=(
/copytest/test1
/copytest/test2/test.conf
/copytest/test3/test3/test3
/copytest/test4/test4
)
CopyFunction() {
for i in "${$1[@]}"; do
rsync -R $2 $3
done
}
CopyFunction 'IPFILE_LIST' $i copytestdest
Where the function would look like this in the end
CopyFunction() {
for i in "${IPFILE_LIST[@]}"; do
rsync -R $i /copytestdest/
done
}
And it would execute each item in the array for rsync, in the end i should get an output of the following
copytestdest/copytest/test1
copytest/test2/test.conf
copytestdest/copytest/test3/test3/test3
copytestdest/copytest/test4/test4
I would also like to support the follow in the same fuction if possible otherwise it will likely need to be another fuction
CopyFunction copytestdest 'IPFILE_LIST'