Help Center/ Huawei Cloud EulerOS/ FAQs/ What Are the Differences Between the grep Commands in HCE 2.0 and in CentOS 7?
Updated on 2026-02-28 GMT+08:00

What Are the Differences Between the grep Commands in HCE 2.0 and in CentOS 7?

Symptom

In HCE 2.0, when grep is used to search for binary files or files containing garbled characters, the message "Binary file xxx matches" is displayed. However, when searching for the same files in CentOS 7, the file content will be displayed.

Possible Cause

CentOS 7 uses grep 2.16, and HCE 2.0 uses grep 3.7. In version 2.22, the logic for processing garbled characters and binary files is changed. A different method is used to detect encoding errors and search for files.

Solution

Use grep -a instead of grep to search for files. Garbled characters and content in binary files will be treated as common characters.