Re: Help needed for 'sed'-ing a Hex file
On Tue, 2003-04-22 at 19:53, David Z Maze wrote:
> Ronald van Engelen <ronalde@lacocina.nl> writes:
>
> > I'm trying to use some commands from base-utils (like sed, grep and awk)
> > to extract a list of filenames from a Cubase generated RIFF file. The
> > file is a HEX file and I'm having the following problems at the start of
> > the process:
>
> (It sounds like you mean a binary file; I'd expect a "hex file" to
> contain only the characters [0-9A-F] and whitespace, and to be a hex
> dump of a binary file.)
yep
>
> >From my memory of looking at .wav files (which really are RIFF files)
> long long ago, the file format is fairly straightforward; you also
> might try writing a Perl/Python script or something similar to
> actually parse the file.
I looked at some RIFF docs from IBM and M$ as well, but it seems Cubase
uses some other features in these files: they're in fact not audio files
but project and pool files, which have pointers to separately stored
.wav files, which are in a recognizable RIFF format. I think they use a
subset or portion of the RIFF specification without the data chunks.
> > 1. Extract text from the hex file:
> > I've looked at hexdump and hexcurses, but both won't let me make a
> > text-only dump of the strings in the hex file.
>
> You might try using strings(1) out of the binutils package.
Never saw this kind of consistency before on the subject of choosing the
right tool for the job.
>
> > The path of the file (D:\Bands\Band
> > X\Projecten\StudioStarsound\Tracks\Kopie van 01
> > Together\VERSIES\BEWERKT\Audio\) is displayed across lines 7, 8 and 9.
> > The actual filename (5 Hi Hat_13.wav) is on line 7.
>
> Do you in fact have a way of finding the start/end of the filenames in
> this format? Again, you might be happier trying to work on the raw
> binary file here.
>
> > 2. KHEXEDIT outputs a standard text file with line-wrapping at column
> > 80. I need to get rid of the EOL markers as well, because the filenames
> > I'm looking for are spread on multiple lines. I've tried a lot but
> > it seems to me that sed can't find strings which are not on one
> > line(?).
>
> Yup. You can use sed to bring in additional lines (with the 'N'
> command), but if I'm doing anything this involved, I've probably
> switched to perl at this point since it's somewhat less arcane for
> this particular sort of work.
>
> --
> David Maze dmaze@debian.org http://people.debian.org/~dmaze/
> "Theoretical politics is interesting. Politicking should be illegal."
> -- Abra Mitchell
Thanks,
Ronald
Reply to: