4

I am attempting to use the zip -r command to zip a folder which includes two files. I need to pass the absolute path of the folder with two files (/path/to/my/files/), which is causing all of the folders to be zipped with it, where as I only need the last folder (files/) and its contents to be zipped, so that when the file is unzipped, there is only one folder and the two files within it. How can I modify the command to be able to pass the absolute paths in the arguments while keeping only the last folder?

Preston
  • 143
  • 1
  • 4

1 Answers1

6

zip operates from the current working directory. If you have to return to the working directory you started from, that can work too.

Try:

cd /path/to/my
zip -r zipfile.zip files/
cd -
Hyppy
  • 15,608
  • 1
  • 38
  • 59
  • Thanks, I didn't think it would be that simple :/ – Preston Jun 11 '12 at 21:02
  • @Preston No problem, simple things can trip up anybody sometimes. It's not like the `zip -h` output is all that helpful to begin with. – Hyppy Jun 11 '12 at 21:04