我无法弄清楚-x
命令 zip 中的选项。我想压缩工作文件夹以将其保存为备份,但我有一些文件和一个包含不需要保存的大文件的目录。因此我想压缩除上面列出的目录之外的整个目录。
这是我的脚本:
#!/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/
答案1
将最后一行修改为,
zip -9 -r /local00/home/F48174/Documents/backup/$filename.zip -x /local00/home/F48174/Documents/scripts_eprou_aster/base\*