让 zless 读取空的 gz 文件

For zless to read empty gz file

我尝试过使用 zless 读取 (.gz) 文件。

zless .txt.gz

但是,当 (.gz) 文件为空时,它会显示一条消息

".txt.gz" may be a binary file.  See it anyway?

如何在不多次键入 Y 的情况下强制 zless 读取一个空的 gz 文件。

有没有可能return像

 is empty 

zless 只是 less 的包装。你需要看看 man less:

-f or --force Forces non-regular files to be opened. (A non-regular file is a directory or a device special file.) Also suppresses the warning message when a binary file is opened. By default, less will refuse to open non-regular files. Note that some operating systems will not allow directories to be read, even if -f is set.

答案是

zless -f ".txt.gz"