I'm trying to write a script that will copy the contents of one directory, send them to ./test/ and append _copy to the file name. Below is my current script. I seem to be unable to append _copy to the file name. Any small suggestions for improvements will help, too.
#!/bin/bash
sourceDir=~sschro15/practice
targetDir=./test/
count=0
if [ -d $sourceDir ] && [ -r $sourceDir ]
then
echo "blah" &> /dev/null
else
echo "Error: $sourceDir is not accessible."
exit 1
fi
if [ -w $sourceDir ]
then
echo "blah" &> /dev/null
else
echo "Error: $sourceDir is not writeable."
exit 1
fi
for file in $sourceDir/*
do
cp -r $file/* ./test/ "$targetDir/_copy"
echo
echo "Copied $file to $sourceDir/_copy"
count=$[ $count + 1 ]
done
echo
echo "$count files have been copied."