Spaces:
Running
Running
File size: 963 Bytes
f6785aa f84932f f6785aa f84932f cf83e39 f84932f 37d6bfd f84932f 37d6bfd fa3c514 3ed3ba5 4a4dd5a f84932f e7ac08a f84932f e7ac08a 547ec04 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
#!/bin/bash
# Verificar si se pasó un archivo como parámetro
if [ -z "$1" ]; then
echo "Uso: $0 archivo_de_entrada"
exit 1
fi
archivo_entrada="$1"
# Verificar si el archivo existe
if [ ! -f "$archivo_entrada" ]; then
echo "El archivo $archivo_entrada no existe."
exit 0
fi
files=$(cat "$archivo_entrada")
# Leer el archivo línea por línea
for linea in $files; do
nombre=$(echo "$linea" | cut -d ":" -f1)
echo "Recuperando $nombre"
valor=$(echo "$linea" | cut -d ":" -f2)
# Crear el directorio si no existe
dir=$(dirname "$nombre")
mkdir -p "$dir"
chmod 777 "$dir"
# Crear el archivo con el contenido adecuado
if [ -z "$valor" ]; then
# Si el valor está vacío, crear un archivo vacío
touch "$nombre"
else
# Si el valor no está vacío, decodificarlo de base64 y escribirlo en el archivo
echo "$valor" | base64 --decode > "$nombre"
fi
chmod 777 $nombre
done
|