Bash – getting bash variable into filename for zip command


In a bash script, how do I use a variable to create a specifically named zipped file? For example, I would like to do something like:

zip -r foo.$VERSION_STRING foo

Where I ideally end up with a file called

It seems like I'm having 2 problems:

  1. the zip command is treating $VERSION_STRING like it's null or empty
  2. the . after foo also seems to be mucking it up

Best Solution

you can use ${VERSION_STRING} to clearly wrap your variable name