As part of a sh script I create a folder I would like to zip. Looking something like this:
my-directory-to-zip
├── file1
├── file2
├── dir1
│ ├── file3
│ ├── file4
When I then zip it the files are then nested inside my-directory-to-zip, where I sould like he folder structure to look something like this inside the zip file:
file1
file2
dir1
├── file3
├── file4
you can imagine my current sh-script looks something like this:
<commands that makes and fills my-directory-to-zip>
zip -r my-zip-file.zip ./my-directory-to-zip
rm -r my-directory-to-zip
I have tried:
<commands that makes and fills my-directory-to-zip>
cd my-directory-to-zip
zip -r ../my-zip-file.zip .
cd ..
rm -r my-directory-to-zip
but that fails with:
bash: cd: my-directory-to-zip: No such file or directory
When I copy pastes the commands directly into the terminal it works perfectly, with the cd into the directory.
question from:
https://stackoverflow.com/questions/65935910/how-to-zip-a-directory-without-having-to-cd-into-the-directory-and-still-keeping 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…