#!/bin/sh echo Introduzca el formato, 1 tar, 2 tar.gz, 3 tar.bz2 read format if [ $format -eq 1 ];then tar cf $1.tar $1 echo Se ha comprimido $1 en $1.tar elif [ $format -eq 2 ];then tar czf $1.tar.gz $1 echo Se ha comprimido $1 en $1.tar.gz elif [ $format -eq 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
La variable format dentro del if va sin comillas y los iguales se pone -eq (=)