hi everyone i did this script :
#!/bin/bash
if [ $# -ne 1 ] ;
then
echo "Errore, puoi immettere solo un argomento"
exit
elif ! [ -d $1 ] ;
then
echo "Errore, "$1" non è una directory"
exit
fi
if [ -e $1.tar.gz ] ;
then
echo "Questo archivio è già esistente,vuoi sovrascriverlo (s/n)? "
read opt
case $opt in
s)
rm -rf $1.tar.gz
tar -czvf $1.tar.gz $1
if ! [ $? -eq 0 ] ;
then
clear
echo "Errore comando non andato a buon fine"
else
clear
echo "L'archvio è stato sovrascritto, questo è il suo contenuto : "
tar ztvf $1.tar.gz
fi
exit
;;
n)
exit ;;
*)
echo "Comando non valido " ;;
esac
else
tar -czvf $1.tar.gz $1
if ! [ $? -eq 0 ] ;
then
clear
echo "Errore comando non andato a buon fine"
else
clear
echo "Archvio creato con successo,il contenuto è : "
tar ztvf $1.tar.gz
fi
fi
I don't understand why on line 38, referring to if [$? -ne 0]
after removing and creating the .tar.gz archive, the terminal gives me "command not found", among other things, I used the same instruction inside the if
of some line of code later ... can someone explain to me where I am wrong?