Unzip a file and then display it in the console in

2019-07-20 03:30发布

I have access to a remote server over ssh. I have only read (no write) access on the server. There is a zipped log file that I want to read. But because I have only read access, I cannot first extract the file and then read it, because when I try to unzip, I get the message Read-only file system.

My idea was to redirect the output of the gunzip-command to some other command that can read from the standrat input and display the content in the console. So I do not write the unzipped file on the file system (that I do not have the right) but display it directly in the console. Until now I couldn't successfully do it.

How to achieve this goal? And is there any better way to do it?

1条回答
霸刀☆藐视天下
2楼-- · 2019-07-20 03:40

Since you do not have permission to unzip the file, you will first need to view the list of contents and their path. Once you get that then you can view content using -p option of unzip command.

  • View contents

    zipinfo your.zip

  • View file contents
    unzip -p latest.zip wordpress/wp-config-sample.php

  • In case it is a .gz file then use: gunzip -c wordpress/wp-config-sample.php

Hope this helps!

查看更多
登录 后发表回答