0

I want to be able to navigate to files located in a zip file from the terminal. I can access the files and directories on the graphical user interface, but I can't seem to use cd to get to them like I can with other folders.

I've tried: cd path/to/.zipfile/and/the/things/inside and even vi path/to/.zipfile/and/a/file/inside but both times I get the error: no such file or directory even though I know for sure that they exist.

I'm not sure how unzipping works- if the unzip releases all the things inside or if you can unzip and pull certain things out and then zip it all back up again pretty easily. I would prefer not to unleash everything inside the zip file, if possible.

Any help would be appreciated!

2

You can use the unzip command with its -l option. man unzip says about the -l option:

list archive files (short format). The names, uncompressed file sizes and modification dates and times of the specified files are printed along with totals for all files specified.

For example you are in ~/sed directory,in which there is a zip file named my.zip, you should do:

me@me-K52JT:~/sed$ unzip -l my.zip 

The output will be:

  Length      Date    Time    Name
---------  ---------- -----   ----
      752  2019-07-10 20:24   a.txt
      101  2019-07-10 18:33   b.txt
---------                     -------
      853                     2 files

So you can see the list of files in your zip without extracting it. The default behavior of unzip (with no options) is to extract into the current directory.

  • 1
    What does the -l option do and what arguments do I need to give it? – Louise Cullen Jul 11 at 14:56
  • If I want to extract a folder located within the zip file, do I do unzip -l .zipfile/path/to/folder? – Louise Cullen Jul 11 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.