bash - 将 bash 变量放入 zip 命令的文件名中

标签 bash zip

在 bash 脚本中,如何使用变量来创建特定命名的压缩文件?例如,我想做这样的事情:

VERSION_STRING='1.7.3'
zip -r foo.$VERSION_STRING foo

理想情况下,我最终会得到一个名为 foo.1.7.3.zip

的文件

我好像有两个问题:

  1. zip 命令将 $VERSION_STRING 视为 null 或空
  2. .foo 之后似乎也搞砸了

最佳答案

你可以使用${VERSION_STRING}来清楚地包装你的变量名

关于bash - 将 bash 变量放入 zip 命令的文件名中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9590034/

相关文章:

linux - 我想了解这个shell脚本

ios - 使用 Swift 解压一个 zip 文件

wix - 是否可以在 WIX 中创建文件夹和文件结构之外的 zip 文件?

ruby-on-rails - 上传 .zip 文件时 Rails 的 Paperclip gem POSTing 而不是 PUTting

python - 在 Python 中将类文件对象添加到 Zip 文件

bash - 使用 bash 创建缩进文本

linux - 无法在 bash 中增加变量

Bash 脚本 : how to get the whole command line which ran the script

linux - 跳过 "find"输出中的字符

powershell - 如何使用 Windows Powershell 提取嵌套文件夹中的所有 zip 文件