I want to zip a directory not everything in the path. I know the command zip -r squash.zip dir1 From the post: How do I zip/unzip on the unix command line?

But when I run the command using the absolute path:

zip -r squash.zip /path/to/dir1

Zip creates folders to the path also and I get in the zip folder /path/to/dir1. What I want is only dir1\sub\dirs

1 Answer 1


it's best to navigate to that specific directory parent and run the zip from there and then store the zip somewhere else. e.g. cd /path/to

zip -r /home/user/dir1.zip dir1/

  • The problem I have is I am running a script and I am using absolute paths. So navigating to a directory is not possible.
    – Whitecat
    Apr 20, 2017 at 0:09
  • you probably want to have something like this question
    – Laywah
    Apr 20, 2017 at 2:47

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.