Home > Mobile >  get the text inside a zipped text file without extraction
get the text inside a zipped text file without extraction

Time:09-23

I want to get the content of the file1.txt of my archive.zip without extrancting the file.
For all these commands I obtain caution: filename not matched: file1.txt

unzip -p ~/archive.zip ~/archive.zip/file1.txt | less
unzip -p ~/archive.zip ~/archive/file1.txt | less
unzip -p ~/archive.zip file1.txt | less

the archive.zip is at the home directory, and the respective names are correct. Hardcoding the path, produces the same undesired outcome:

unzip -p /home/pi/archive.zip ~/archive.zip/file1.txt | less
unzip -p /home/pi/archive.zip ~/archive/file1.txt | less
unzip -p /home/pi/archive.zip file1.txt | less

I am trying to do this in a raspberry-pi. The expected output is the content of the file1.txt.

CodePudding user response:

It's possible that the zip extracts into a directory and the file is present there, eg file.zip creates a someproject-name top level directory and the contents are under that. So you can do something like this:

unzip -p /home/pi/archive.zip '*/file1.txt' So it would look at the top level directory aswell due to the glob.

  • Related