Hello i have got problem, on shell program(.sh), with this code I should copy the file JPG from the directory sorgente to destinazione but the code does not work, can you help me!!
#!/bin/bash
sorgente=$1
destinazione=$2
cd sorgente
for i in *.jpg
do
#controllo che la directory sia leggibile
if test -r $i
then
#controllo che il file $i non sia presente nella destinazione
if test -r $2
then
#in questo caso è presente nella destinazione
mv $i "$destinazione/duplicati"
else
mv $i "$destinazione"
fi
else
echo "il file $i non è leggibile da questo utente"
fi
done
cd sorgentewithout$and you probably wantcd "$sorgente"test -r $2tests if the directory is readable, that's not the same as testing if it already contains a file named$i.mvhas a--backupswitch that can generate afoo.jpg.1in the target directory iffoo.jpgalready exists there.