linuxbashsedgrep

How can I extract the text portion of a binary file in Linux/Bash?


I have a binary file. If I open it with vi, it shows sequences of human-readable text and binary characters. What is the best way to extract the human-readable portion only using Bash?

I was thinking, maybe we can do this over a grep or sed pattern?

cat file1.bin | grep '????'  > newfile.txt

Solution

  • Use the strings utility - that's exactly what it's designed for.

    Install:

    sudo apt-get install binutils
    

    Then use it like this:

    string filename