Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6025589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:19:19+00:00 2026-05-23T04:19:19+00:00

Does anyone know how to get grep, or similar tool, to retrieve offsets of

  • 0

Does anyone know how to get grep, or similar tool, to retrieve offsets of hex strings in a file?

I have a bunch of hexdumps (from GDB) that I need to check for strings and then run again and check if the value has changed.

I have tried hexdump and dd, but the problem is because it’s a stream, I lose my offset for the files.

Someone must have had this problem and a workaround. What can I do?

To clarify:

  • I have a series of dumped memory regions from GDB (typically several hundred MB)
  • I am trying to narrow down a number by searching for all the places the number is stored, then doing it again and checking if the new value is stored at the same memory location.
  • I cannot get grep to do anything because I am looking for hex values so all the times I have tried (like a bazillion, roughly) it will not give me the correct output.
  • The hex dumps are just complete binary files, the paterns are within float values at larges so 8? bytes?
  • The patterns are not line-wrapping, as far as I am aware. I am aware of the what it changes to, and I can do the same process and compare the lists to see which match.

Perl COULD be a option, but at this point, I would assume my lack of knowledge with bash and its tools is the main culprit.

Desired output format

It’s a little hard to explain the output I am getting since I really am not getting any output.

I am anticipating (and expecting) something along the lines of:

<offset>:<searched value>

Which is the pretty well standard output I would normally get with grep -URbFo <searchterm> . > <output>

What I tried:

A. Problem is, when I try to search for hex values, I get the problem of if just not searching for the hex values, so if I search for 00 I should get like a million hits, because thats always the blankspace, but instead its searching for 00 as text, so in hex, 3030.
Any idea’s?

B. I CAN force it through hexdump or something of the link but because its a stream it will not give me the offsets and filename that it found a match in.

C. Using grep -b option doesnt seem to work either, I did try all the flags that seemed useful to my situation, and nothing worked.

D. Using xxd -u /usr/bin/xxd as an example I get a output that would be useful, but I cannot use that for searching..

0004760: 73CC 6446 161E 266A 3140 5E79 4D37 FDC6  s.dF..&j1@^yM7..
0004770: BF04 0E34 A44E 5BE7 229F 9EEF 5F4F DFFA  ...4.N[."..._O..
0004780: FADE 0C01 0000 000C 0000 0000 0000 0000  ................

Nice output, just what I want to see, but it just doesn’t work for me in this situation..

E. Here are some of the things I’ve tried since posting this:

xxd -u /usr/bin/xxd | grep 'DF'
00017b0: 4010 8D05 0DFF FF0A 0300 53E3 0610 A003  @.........S.....

root# grep -ibH "df" /usr/bin/xxd
Binary file /usr/bin/xxd matches
xxd -u /usr/bin/xxd | grep -H 'DF'
(standard input):00017b0: 4010 8D05 0DFF FF0A 0300 53E3 0610 A003  @.........S.....
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:19:20+00:00Added an answer on May 23, 2026 at 4:19 am

    We tried several things before arriving at an acceptable solution:

    xxd -u /usr/bin/xxd | grep 'DF'
    00017b0: 4010 8D05 0DFF FF0A 0300 53E3 0610 A003  @.........S.....
    
    
    root# grep -ibH "df" /usr/bin/xxd
    Binary file /usr/bin/xxd matches
    xxd -u /usr/bin/xxd | grep -H 'DF'
    (standard input):00017b0: 4010 8D05 0DFF FF0A 0300 53E3 0610 A003  @.........S.....
    

    Then found we could get usable results with

    xxd -u /usr/bin/xxd > /tmp/xxd.hex ; grep -H 'DF' /tmp/xxd
    

    Note that using a simple search target like ‘DF’ will incorrectly match characters that span across byte boundaries, i.e.

    xxd -u /usr/bin/xxd | grep 'DF'
    00017b0: 4010 8D05 0DFF FF0A 0300 53E3 0610 A003  @.........S.....
    --------------------^^
    

    So we use an ORed regexp to search for ‘ DF’ OR ‘DF ‘ (the searchTarget preceded or followed by a space char).

    The final result seems to be

    xxd -u -ps -c 10000000000 DumpFile > DumpFile.hex
    egrep ' DF|DF ' Dumpfile.hex
    
    0001020: 0089 0424 8D95 D8F5 FFFF 89F0 E8DF F6FF  ...$............
    -----------------------------------------^^
    0001220: 0C24 E871 0B00 0083 F8FF 89C3 0F84 DF03  .$.q............
    --------------------------------------------^^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know a way to get the mean amplitude of a .wav file
Does anyone know how to get the IP address in decimal or hex from
Does anyone know how to get amex authorized with authorize.net? I have authorize set
Does anyone know how to get a specific type of file from matlab from
Does anyone know how to get a csv url file and convert it to
Does anyone know how to get the operating system information from a microsoft sql
Does anyone know how to get the correct mouse position during a drag-and-drop operation
Does anyone know how to get the list of items and check/uncheck items in
Does anyone know why I get undefined method `my_method' for #<MyController:0x1043a7410> when I call
Does anyone know how to get the blur event to fire on the document

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.