Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- fecha=$(date +%s)
- # tiene que ser un archivo
- archivo_origen=$1
- # [ -f ... ] es lo mismo que test -f ...
- if [ -f "$archivo_origen" ]; then
- # se guarda nombre de archivo sin ruta
- nombre_archivo=$(basename $archivo_origen)
- else
- echo "El archivo no exite."
- exit 1
- fi
- # tiene que ser un directorio
- # '%/' elimina la barra al final de la cadena
- ruta_destino=${2%/}
- test -d $ruta_destino && \
- { cp $archivo_origen ${ruta_destino}/${nombre_archivo}.${fecha}; \
- gzip ${ruta_destino}/${nombre_archivo}.${fecha}; \
- ls -1 ${ruta_destino}/*.gz; } || { echo no existe el directorio; exit 1; }
Advertisement
Add Comment
Please, Sign In to add comment