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?

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'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.