Zip all files in a directory, but don’t include the top directory in the archive

terminalunixzip

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?

Best Answer

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

Optionally

mv filename.zip /some/other/path
Related Question