Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

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 -
share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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