How can I compress a directory content without compress the full path folder structure too.

I am using this command to zip a folder content under var/www/ directory, but when I unzip the application.zip I got a 2 level folder structure

/var/www/my important files

zip -r /var/appbackup/application.zip /var/www/

I would like to keep only files without "var" and "www" folders. How can I do that?

2 Answers 2

cd /var/www
zip -r application.zip *

It should work fine.


if you're ok with using 7z instead of zip:

7z a -tzip -mx5 /home/"$USER"/Desktop/target_file.7z "/directory/to/be/compressed";

this yields a normal-compressed (-mx=5) zip (-tzip) archive. you can switch the parameters around by refering to the man file or this guide http://www.dotnetperls.com/7-zip-examples

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .