1

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

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Whitecat
  • 300
  • 3
  • 12

1 Answers1

2

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/

Laywah
  • 66
  • 5
  • 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 '17 at 00:09
  • you probably want to have something like this [question](http://stackoverflow.com/questions/786376/how-do-i-run-a-program-with-a-different-working-directory-from-current-from-lin) – Laywah Apr 20 '17 at 02:47