Linux命令变量替换

标签 linux bash zip sh

我想压缩所有文件/目录,同时排除变量 $excludes 中列出的一些文件/目录。但是下面的代码并不排除这些文件。

excludes='"dir1/*" "dir2/*" "dir3/*"'
zip -r zipfile * -x $excludes 

最佳答案

这应该有效:

zip -r zipfile * -x dir1/* dir2/* dir3/*

或者甚至这应该有效:

excludes='dir1/* dir2/* dir3/*'
zip -r zipfile * -x "$excludes"

关于Linux命令变量替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22620960/

相关文章:

linux - 为什么 find 的 -exec 选项包含 'non-matched' 项?

linux - 枚举 389/Fedora 目录服务器的客户端

bash - 比较不区分大小写的字符串,然后计算重复项

linux - 带有 cron 作业的 Shell 脚本在未运行的情况下启动程序?

linux - Kprobe on Linux Scheduler 和查找 linux 调度程序

bash - 在我的 .bash_profile 中正确格式化 PYTHONPATH

linux - 使用 tr 命令将单个单词变为大写

python - 我如何让我的 Python 程序解压缩我拖过的压缩文件?

delphi - KaZip for C++Builder2009/Delphi

lua - 可以在 corona 中制作 zip 文件吗?