I'm in a directory and I have a zip containing files and directories. I need to unzip that file, into current directory, but preserving the file structure.
unzip myfile.zip will create a myfile directory in current directory which is not what I want.
unzip -j myfile.zip will kill all the file strucure, which is not what I want.
unzip myfile.zip
extracts files in the working directory by keeping path names from the zip file.
So if you get a subdirectory myfile
it means it is part of the relative path of compressed files. Check it by listing the zip content
unzip -l myfile.zip
So you can unzip the file from the directory above, or, from the target directory unzip with -d
option, where -d is the directory above
cd myfile
unzip myfile.zip -d ..
Dont select the folder while zipping. For example myfile/abc.txt and myfile/efg.txt so while zipping select the files (abc.txt,efg.txt) and zip dont select the myfile folder to zip. So that when you unzip the file, the parent dir for each file or folder will be the directory in which you unzip.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With