0

I can't manage to figure out the -x option in the command zip. I want to compress a working folder to save it as a backup, but I have some files and a directory that contains huge files that I don't need to save. Therefore I would like to compress the whole directory except for the one listed above.

Here is my script:

#!/bin/bash
clear
echo "Saving all work directory in the backup"

now=$(date +'%Y_%m_%d')
filename=($(echo "backup_"$now))
cd /local00/home/F48174/Documents/scripts_eprou_aster/
echo "... removing /base because it's huge ..."

zip -9 -r /local00/home/F48174/Documents/backup/$filename.zip  -x /local00/home/F48174/Documents/scripts_eprou_aster/base/
  • You need to tell zip what has to be zipped: zip -r archive.zip folder_to_zip -x file_not_to_zip – Jasper May 12 '14 at 8:30
0

Modify the last line to be,

zip -9 -r /local00/home/F48174/Documents/backup/$filename.zip  -x /local00/home/F48174/Documents/scripts_eprou_aster/base\*

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.