
我有幾個日誌文件,其中包含一些不可顯示字元的位元組(由於請求上的二進位簽名)。
每次我用更少的錢打開它們時,我都會被問到:
$ 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
預設使用.bashrc 運行-f
。
export LESS='-f'