如何在无需确认的情况下减少打开二进制文件的数量?

如何在无需确认的情况下减少打开二进制文件的数量?

我有几个日志文件包含一些不可显示的字符(由于请求上的二进制签名)。

每次我用 less 打开它们时,我都会被问到:

$ less /var/log/file.log       
"/var/log/file.log" may be a binary file.  See it anyway? 

如何使用命令行选项或配置来跳过这一步?

答案1

使用-f选项:

-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.

您可以将此选项添加到LESS.bashrc 中的环境变量中,以便less默认运行-f

export LESS='-f'

相关内容