I know for a fact this is going to be something completely simple and i'm going to have missed the most basic of things but I cannot get my head around this.
file=( $(find $DIRECTORY -maxdepth 1 -type f) )
total=$(find $DIRECTORY -type f | wc -l)
count=0
while [ "$count" -lt "$total" ]
do
for f in "$file";
do
echo -n "Would you like to copy $file? "
read yn
case $yn in
Y | y )
cp $f $TARGET
chmod =r $TARGET/$(basename $file)
count=$((count + 1))
;;
N | n )
echo "skipping"
count=$((count + 1))
;;
* ) echo "Please enter Y or N"
exit 1
;;
esac
done
done
(sorry about formatting).
basically it's doing this at the moment
you input the source file and target file. works fine
$ ./script.sh ~/work ~/folder
Created target directory.
Would you like to copy /home/USER/work/cash.sh?
then you either type y / n
either of them only gives the same response.
$ ./script.sh ~/work ~/folder
target directory exists, starting copy
Would you like to copy /home/USER/work/cash.sh? y
Would you like to copy /home/USER/work/cash.sh? y
basically it does copy that cash.sh file and it knows there are 2 files in the directory, it just doesn't skip to the next file and stays on the same one and i'm not sure how to fix that at all.
Honestly I've been staring at this for the past few hours and its driving me insane, anything would be of help. Thanks in advance.