Find Positions of a Hexadecimal Sequence in a File

This page answers questions like these:


Related Links:
Count Occurrences of a Hexadecimal Sequence in a File
Count Occurrences of a String in a File
Output the Lines Between Two Matching Lines
Output Lines of a File in Reverse Order
Replace Text in a File using the Command Line
Join Lines of Text File Together
Find and/or Replace a Tilde in Excel
Find: Path Must Precede Expression



Detect Whether A File Contains A Hexadecimal String:

grep -P '\xNN\xNN\xNN...' FILE

Find Positions of a Hexadecimal Sequence in a File:

od -v -t x1 FILE | sed 's/[^ ]* *//' | tr '\012' ' ' | grep -b -i -o HEXSTRING | sed 's/:.*/\/3/' | bc od -v -t x1 FILE | sed 's/[^ ]* *//' | tr '\012' ' ' | sed 's/HEXSTRING/FOUND\n&/g' | tr ' ' '\012' | grep -n FOUND | sed 's/\([^:]*\):.*/v=\1;d=d+1;v-d;/' | bc


Related Links:
Count Occurrences of a Hexadecimal Sequence in a File
Count Occurrences of a String in a File
Output the Lines Between Two Matching Lines
Output Lines of a File in Reverse Order
Replace Text in a File using the Command Line
Join Lines of Text File Together
Find and/or Replace a Tilde in Excel
Find: Path Must Precede Expression

Home  >  Linux / Unix  >  Find Positions of a Hexadecimal Sequence in a File


Tags: grep hex, hex grep, find hex in file, byte sequence, hexadecimal sequence, hex sequence, hexadecimal string, hex string, hexadecimal pattern, hex pattern, binary pattern, file, text file, binary file, linux, unix, solaris, bsd, aix

Copyright © HelpDoco.com
file-find-hexadecimal.txt
Linux-Unix/find-positions-of-hexadecimal-sequence-in-file.htm
2