How do I make less open binary files without confirmation?

4

I have several log files that contain a few bytes which are not displayable characters (due to binary signatures on the requests).

Every time I open them with less I get asked:

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

How do I make less skip this step with a command line option or configuration?

giorgiosironi

Posted 2014-09-01T09:42:19.320

Reputation: 393

Answers

7

Use -f option:

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

You can add this option to LESS environment variable in .bashrc to run less by default with -f.

export LESS='-f'

jimmij

Posted 2014-09-01T09:42:19.320

Reputation: 361