Normally I use zip command with:
zip -r my_arch.zip my_folderNow I am using zip in an bash script in this way:
#!/bin/bash
OUT=$1
NAME=$2
zip -r -q $OUT/$NAME $OUT/$NAMEI call the script with:
./mySrcipt /home/edevise/foo myFilesOpening the resulting zip file shows, that the full path was used to zip the folder foo. E.g. opening the zip file shows the home folder and I need to navigate through all subsequent folders until I see my folder foo.
How to adapt the script to zip the folder foo, only?
PS: Please don't wonder about the sense of the script. It is just an example to show the problem.
41 Answer
If you want only relative paths in the zip file, you should add a cd command to your script:
#!/bin/bash
OUT="$1"
NAME="$2"
cd "$OUT"
zip -r -q "$NAME" "$NAME"
cd - 1