Skip to content

Instantly share code, notes, and snippets.

@hugosolar
Last active December 19, 2015 00:49
Show Gist options
  • Save hugosolar/5871440 to your computer and use it in GitHub Desktop.
Save hugosolar/5871440 to your computer and use it in GitHub Desktop.
bash script que comprueba si archivos css en origen son mas nuevos que los del destino y los copia. y si no existe el directorio lo crea.
#!/bin/bash
for file in ./front-themes/*; do
if [ -d $file ]; then
DIRECTORY="${file##"./front-themes/"}"; #obtenemos el nombre del directorio de origen y lo aislamos (debe haber algo mas elegante para hacerlo)
if [[ "$DIRECTORY" == *"-2013" ]]; then
STYLE1="$file/style.css"; #archivo fuente
STYLE2="./htdocs/wp-content/themes/$DIRECTORY/style.css"; #archivo destino
DIRECTORY2="./htdocs/wp-content/themes/$DIRECTORY/"; #directorio de destino
if [[ "$STYLE1" -nt "$STYLE2" ]]; then #comparamos si origen es mas nuevo que destino
if [ ! -d "$DIRECTORY2" ]; then #si no existe el directorio
mkdir $DIRECTORY2; #creamos el directorio
fi;
cp $STYLE1 $STYLE2;
echo "-- Copiado $DIRECTORY --";
else
echo "-- $DIRECTORY no ha sido modificado --";
fi;
fi;
fi;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment