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:
VERSION_STRING='1.7.3' zip -r foo.$VERSION_STRING foo
Where I ideally end up with a file called foo.1.7.3.zip
It seems like I'm having 2 problems:
$VERSION_STRING
like it's null or empty.
after foo
also seems to be mucking it upSyntax : $zip –m filename.zip file.txt 4. -r Option: To zip a directory recursively, use the -r option with the zip command and it will recursively zips the files in a directory. This option helps you to zip all the files present in the specified directory.
The easiest way to zip a folder on Linux is to use the “zip” command with the “-r” option and specify the file of your archive as well as the folders to be added to your zip file. You can also specify multiple folders if you want to have multiple directories compressed in your zip file.
If you want to retrieve the filename without extension, then you have to provide the file extension as SUFFIX with `basename` command. Here, the extension is “. txt”.
you can use ${VERSION_STRING}
to clearly wrap your variable name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With