i need to zip my directory from other location

/a/b/c $ zip -r x.zip /tmp/w/x 

creates the entire path in zip, when i unzip

unzip x.zip 

It creates /tmp/w/ also in current folder, i don't want that.


Assuming you just want x,

(cd /tmp/w;zip -r "$file" x)

does the job in a subshell. When the subshell exits, the cd wears off.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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