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
link|improve this question

25% accept rate
1  
How does the output relate to the example? – Ignacio Vazquez-Abrams Nov 29 '10 at 9:55
feedback

2 Answers

( cd /var/www ; zip -r - test1 ) > output.zip
link|improve this answer
this is correct regardless of duplicate +1 – aking1012 Nov 29 '10 at 17:55
feedback

Does find . ! -name "*.zip" -type f -print | zip test -@ do what you want?

link|improve this answer
zip is capable of recursing a path on its own. – Ignacio Vazquez-Abrams Nov 29 '10 at 10:01
I updated the question. This is not what I need. – user56301 Nov 29 '10 at 10:23
@user, I updated the question -- adding "need it" is hardly an update! (Also, please come up with a better title?) – Arjan Nov 29 '10 at 12:10
@Ignacio and Charles, so maybe zip -r -x *.zip would achieve the same? – Arjan Nov 29 '10 at 12:30
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.