Search code examples
linuxzipunzip

linux zip command not contains parent folder


I have a question about zip cmd in linux ,when I want to zip a folder and its sub files,but I won't zip it contains the folder name ,I use the cmd as that: zip -r foldername.war foldername/. but when I unzip the foldername.war to folder like this: zip foldername.war -d foldername . The dir will be foldername/foldername/files.I don't want this ,I just want foldername/files


Solution

  • I am not sure how you are using zip and unzip command, but you can follow below steps for directories :-

    To zip a dir issue following command :-

    zip -r foldername.war foldername/

    To unzip a zip file, issue following command :-

    unzip foldername.war

    you will have following structure :-

    tree foldername

    foldername
    |-- a
    |-- b
    `-- c