Help - Search - Members - Calendar
Full Version: Tool For Finding / Deleting Byte Sequences In File
OESF Forums > General Forums > General Support and Discussion > Software
daniel3000
Hello,

is there a tool which is able to find a given byte sequence in a file and delete that sequence?

I mean something like sed for binary files, I need to do something like

sed -e '/3C 00 75 00 6C 00 3E 00 0A 00 09 00 09 00 3C 00 2F 00 75 00 6C 00 3E/d'

(I know this won't work, as sed does not do byte-level editing, it's only an example in a kind of pseudo code).

My problem is this:
I want to process a text file this way, so sed would actually be the tool to choose. But the string I want to delete contains a newline, and even with the N command of sed I was not able to create a suitable sed command.
So now I'm looking for something which works on the byte level.

Thanks for any hint

daniel
sidmoraes
QUOTE(daniel3000 @ Jun 2 2006, 06:01 AM)
Hello,

is there a tool which is able to find a given byte sequence in a file and delete that sequence?

I mean something like sed for binary files, I need to do something like

sed -e '/3C 00 75 00 6C 00 3E 00 0A 00 09 00 09 00 3C 00 2F 00 75 00 6C 00 3E/d'

(I know this won't work, as sed does not do byte-level editing, it's only an example in a kind of pseudo code).

My problem is this:
I want to process a text file this way, so sed would actually be the tool to choose. But the string I want to delete contains a newline, and even with the N command of sed I was not able to create a suitable sed command.
So now I'm looking for something which works on the byte level.

Thanks for any hint

daniel
*


try with "tr -d ..."
iamasmith
or awk if you have it in your distro
uth
I recently had a similar problem at work, replacing text that contained newlines. I did manage to get it working with sed. I found some examples online that helped.

When I get to work monday, I'll look it up and post my example, if you haven't found an answer by then
Meanie
if you want to remove a complete line from a text file, you ca also simply use grep,

ie

grep -v "some text" ....
daniel3000
QUOTE(Meanie @ Jun 3 2006, 10:29 AM)
if you want to remove a complete line from a text file, you ca also simply use grep,

ie

grep -v "some text" ....
*


Hi Meanie,

I want to remove two lines of text, but only if the first one only contains " <ul>\n" and the second one only contains " </ul>\n". That can occur many times in the source file.

I found bbe, which is a stream editor similar to sed, but works on binary sequences.
I'll use that one I think, since the byte sequence is alweays the same, it can be handled nicely with bbe.
bbe compiled nicely on the Zaurus.
Seems to be a useful too,. I'll make an IPK soon.

There is another approach to solve this problem, because the source file is generated from an XML using XSLT. So if I find a way to prevent the XSLT to generate these empty <ul>s, this would be of course the more elegant solution.
But I have no clue how to do this. Have asked in some XML/XSLT forums. Maybe this will bring a working solution.

Thanks so far!

daniel
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2014 Invision Power Services, Inc.