Can grep search binary files?

QuestionsQuestions4 SkillsProUser Account ManagementOct, 07 2025
0237

Yes, grep can search binary files, but by default, it may not display the output in a human-readable format. To search binary files, you can use the -a option (or --text), which treats binary files as text files. Here's how to do it:

grep -a 'pattern' binaryfile

Example

To search for the word "example" in a binary file named file.bin:

grep -a 'example' file.bin

Additional Options

  • If you want to search for binary files specifically, you can use the -I option to ignore binary files:
    grep -I 'pattern' *
    

If you have more questions or need further assistance, feel free to ask!

0 Comments

no data
Be the first to share your comment!