[TriLUG] How to look for 0xFE using grep?

Robert Dale robdale at gmail.com
Sun Mar 11 19:23:32 EDT 2007


On 3/11/07, Steve Litt <slitt at troubleshooters.com> wrote:
> Hi all,
>
> I'm trying to find lines with binary 254 characters, and cannot find them.
>
> I've tried
>
> grep "\0xFE" infile
>
> That produced no output, even though there are many lines with binary 0xFE, at
> least according to Vim.

Is this a binary or text file? And what are you trying to exactly?

For grep, you would have to put in the character representation of
0xfe since it matches strings.

You could use od -x or hexdump to turn it into hex and then | egrep "
fe|fe |fe$".  This would give you the offsets.

You could also do it programatically.  Perl would probably be the easiest.

-- 
Robert Dale



More information about the TriLUG mailing list