Build Zip archive, special cases

zip

How can I create a zip in a linux distro and
– keep only the relative path to a folder
– put some files in a separate folder inside the zip

I need to do this in a bash script so if i just use the absolute path the entire path will be inside the zip.

Example

/home/user/folder/1.txt
/home/user/folder/2.txt

Output Need It :

test.zip
folder/1.txt
folder/secondfolder/2.txt

Best Answer

( cd /var/www ; zip -r - test1 ) > output.zip
Related Question