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:

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, 2014 at 8:30

1 Answer 1


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\*

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .