Zip all files in a directory, but don't include the top directory in the archive
Solution 1
cd /path/to/your/folder/www
zip -r filename.zip *
Optionally
mv filename.zip /some/other/path
Solution 2
7z a -tzip filename.zip -w /var/www/.
Hidden files included.
Related videos on Youtube
Svish
Software Developer, Geek, HSP, SDA, ..., open, honest, careful, perfectionist, ... Currently into indoor rowing and rock climbing, just to mention something non-computer-related... Not the best at bragging about myself... so... not sure what more to write... 🤔
Updated on September 18, 2022Comments
-
Svish over 1 year
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 ofwebroot/
.Any able to help with how to do this correctly in the terminal?
-
Ƭᴇcʜιᴇ007 over 12 yearsWhich commands and arguments are you using to make the Zip?
-
-
Svish over 12 yearsWill this include hidden files?
-
Joshua Robinson about 8 years* does include hidden files.
-
Trevor Sullivan about 7 yearsWhat if I don't want to
cd
to the directory first? -
kodlan almost 4 yearszip -r -j filename.zip folder_name
-
Jeppe about 3 years@kodlan Thanks! You should add this as an answer. The
-j
argument solved it for me. Fromman 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). -
sny almost 3 yearsDoes not include hidden file/folders