3

Can't quite figure out how to do this right. I have a folder with a website in /var/www

I want to create a zip file with all of it, which when I decompress it does not include the top directory. In other words, the "top" of the zip file should not be the www directory, but the files inside that directory. Hope that made sense...

Reason why I need it is because I need to upload my website as a zip file and then unzip it in place. And won't work if it then unzips to webroot/www/ instead of webroot/.

Any able to help with how to do this correctly in the terminal?

1
  • 1
    Which commands and arguments are you using to make the Zip? Oct 3, 2011 at 18:40

2 Answers 2

4
cd /path/to/your/folder/www
zip -r filename.zip *

Optionally

mv filename.zip /some/other/path
6
  • Will this include hidden files?
    – Svish
    Oct 3, 2011 at 19:33
  • * does include hidden files. Apr 11, 2016 at 8:10
  • 5
    What if I don't want to cd to the directory first? Apr 21, 2017 at 16:58
  • 3
    zip -r -j filename.zip folder_name
    – kodlan
    Jul 12, 2020 at 11:19
  • @kodlan Thanks! You should add this as an answer. The -j argument solved it for me. From man zip: Store just the name of a saved file (junk the path), and do not store directory names. By default, zip will store the full path (relative to the current directory).
    – Jeppe
    Apr 26, 2021 at 12:34
3

7z a -tzip filename.zip -w /var/www/.

Hidden files included.

You must log in to answer this question.

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