El código del script es
Código:
#!/bin/sh
echo Introduzca el formato, 1 tar, 2 tar.gz, 3 tar.bz2
read format
if [ "$format" == 1];then
tar cf $1.tar $1
echo Se ha comprimido $1 en $1.tar
elif [ "$format" == 2];then
tar czf $1.tar.gz $1
echo Se ha comprimido $1 en $1.tar.gz
elif [ "$format" == 3];then
tar cjf $1.tar.bz2 $1
echo Se ha comprimido $1 en $1.tar.bz2
else
echo Formato no incluido, reinicie el script
fi
Y el código del error que saco depués es echo Introduzca el formato, 1 tar, 2 tar.gz, 3 tar.bz2
read format
if [ "$format" == 1];then
tar cf $1.tar $1
echo Se ha comprimido $1 en $1.tar
elif [ "$format" == 2];then
tar czf $1.tar.gz $1
echo Se ha comprimido $1 en $1.tar.gz
elif [ "$format" == 3];then
tar cjf $1.tar.bz2 $1
echo Se ha comprimido $1 en $1.tar.bz2
else
echo Formato no incluido, reinicie el script
fi
Código:
joselucross@Cross-PC:~$ comprimir prueba
Introduzca el formato, 1 tar, 2 tar.gz, 3 tar.bz2
2
/home/joselucross/.scripts/.comprimir.sh: línea 4: [: falta un `]'
/home/joselucross/.scripts/.comprimir.sh: línea 7: [: falta un `]'
/home/joselucross/.scripts/.comprimir.sh: línea 10: [: falta un `]'
Formato no includio, reinicie el script
joselucross@Cross-PC:~$
Introduzca el formato, 1 tar, 2 tar.gz, 3 tar.bz2
2
/home/joselucross/.scripts/.comprimir.sh: línea 4: [: falta un `]'
/home/joselucross/.scripts/.comprimir.sh: línea 7: [: falta un `]'
/home/joselucross/.scripts/.comprimir.sh: línea 10: [: falta un `]'
Formato no includio, reinicie el script
joselucross@Cross-PC:~$