I am trying to write a bash/shell script to zip up a specific folder and ignore certain sub-dirs in that folder.
This is the folder I am trying to zip "sync_test5":
My bash script generates an ignore list (based on) and calls the zip function like this:
#!/bin/bash SYNC_WEB_ROOT_BASE_DIR="/home/www-data/public_html" SYNC_WEB_ROOT_BACKUP_DIR="sync_test5" SYNC_WEB_ROOT_IGNORE_DIR="dir_to_ignore dir2_to_ignore" ignorelist="" if [ "$SYNC_WEB_ROOT_IGNORE_DIR" != "" ]; then for ignoredir in $SYNC_WEB_ROOT_IGNORE_DIR do ignorelist="$ignorelist $SYNC_WEB_ROOT_BACKUP_DIR/$ignoredir/**\*" done fi FILE="$SYNC_BACKUP_DIR/$DATETIMENOW.website.zip" cd $SYNC_WEB_ROOT_BASE_DIR; zip -r $FILE $SYNC_WEB_ROOT_BACKUP_DIR -x $ignorelist >/dev/null echo "Done"
Now this script runs without error, however it is not ignoring/excluding the dirs I've specified.
So, I had the shell script output the command it tried to run, which was:
zip -r 12-08-2014_072810.website.zip sync_test5 -x sync_test5/dir_to_ignore/**\* sync_test5/dir2_to_ignore/**\*
Now If I run the above command directly in putty like this, it works:
So, why doesn't my shell script exclude working as intended? the command that is being executed is identical (in shell and putty directly).