grep outputs "binary file matches" for non UTF-8 encoding text files in RHEL 8 or later

Solution Verified - Updated -

Issue

  • Non UTF-8 encoding (such as SJIS) text files are treated as binary files by grep in RHEL 8 or later.
  • RHEL 8 grep detect some files as binary files For example, /etc/udev/hwdb.bin which were treated as text files in RHEL 7 grep.

    $ grep LANG /etc/udev/hwdb.bin
    grep: /etc/udev/hwdb.bin: binary file matches
    

Environment

  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 9
  • grep

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content