[X-Unix] text file parsing?
Ben Gold
bgold at acedsl.com
Wed May 3 06:40:16 PDT 2006
I'm trying to write a bash script for something I thought would be
simple, but haven't been able to figure it out.
I have some files that are essentially text files, but have binary
data in them. For instance, using grep I need to use the "-a" option
to get any output.
When one opens these files in a text editor you see a readable text
file. However, the first line of the file is a few "garbage"
characters, and the last 1-10 pages are all "garbage" binary characters.
All I'd like to do is make a script that would strip off the first
line and then remove all the garbage characters from the end of the
file. The text of the files always end with the same set of
characters so I had hoped to find a way to basically do something like:
delete from the end of $EndString to the end of the file
where $EndString would be the last text I want to keep and is unique
in the file.
The fact that the file has binary data may make line counting hard,
grep didn't seem to be able to return a line number.
Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.themacintoshguy.com/pipermail/x-unix/attachments/20060503/915dd102/attachment-0001.html
More information about the X-Unix
mailing list