Skip to content
Advertisement

How do I locate a string in a binary file? (No, not the strings command.)

I know about the very useful “strings” command. It will print all the printable strings in a binary file.

But what I want is a command that will tell me the location (in bytes or whatever — I’ll take anything.) of a string in a binary file. Is there a way to get this in Linux?

Advertisement

Answer

The strings command has the ability to display the starting location in bytes of the string using the “-td” option. Below is an example output. The first number is the starting byte number, so the string “linux” below starts at byte 1876 in the file.

1876 linux

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement