Search code examples
linuxcommand-linezip

How to zip contents of a folder in linux command line


So i have a folder structure like MyFolder/File1, MyFolder/File2 .... MyFolder/FileN

I want to zip all the contents of MyFolder to MyFolder.zip such that on unzipping MyFolder.zip the contents are File1, File2 ... FileN

I want to do this using the linux command line.

I saw a method using the -r option of the zip command but the issue is that it creates a MyFolder.zip that on unzipping gives MyFolder. I do not want the MyFolder in it. I want it to directly give me the contents of MyFolder.

Any help will be appreciated. Thanks


Solution

  • You might enter the directory first before running the zip command (output file should be elsewhere for speed & to avoid warning "file changed during compression" on the zip file itself

    zip ../toto.zip . -r 
    

    for example