To get the content of a zipped file, you can do unzip -p archive.zip file1.txt | less
as said here
However, for that is for the case where you are "positioned" in the path where your .zip is. If you are not (for the case the command being executed in a shell script for example), I guess I would need to pass in the absolute paths for the .zip and the file, but a filename not matched:
error is thrown.
For a .zip in the home directory I tried this commands:
unzip -p ~/archive.zip ~/archive.zip/file1.txt | less
unzip -p ~/archive.zip ~/archive/file1.txt | less
but I get the filename not matched:
error.
How can I get the content of a txt file, without unzipping using absolute paths? (meaning not having to be in the specific directory of the .zip to run the command or to be able to perform that task form other path or a shell script)
~/
) is incorrect. Tryunzip -l ~/archive.zip
to see the exact path of file1.txt within the zipfile, not in the file system. I.e., probably justunzip -p ~/archive.zip file1.txt | less
(though it could besubdir/file1.txt
)