[X-Unix] text file parsing?

Wing Wong wingedpower at gmail.com
Wed May 3 11:18:35 PDT 2006


Depending on the version of sed, you can use parenthesis around the
pattern and then \1 to put the pattern back. Since you are deleting
all lines after the pattern, you might want to insert a newline and a
recognizable keyword after the pattern, then delete everything after
the keyword.

goggling for : sed, substitution, \1 or variables, buffers

Good luck!

Oh, if you happen to know what kind of file you are dealing with,
there might already be an interpreter for it, which can do a
[format]=>[ascii/text] conversion for you. Which would be alot easier
going in the long run.

Wing.

On 5/3/06, Ben Gold <bgold at acedsl.com> wrote:
> Björn, Robert,
>
> Thanks... almost there.
>
> The strings command got rid of the binary garbage and effectively
> deleted the first line.  I'm still left with a bunch of ASCII garbage
> at the end of the file.
> Using sed, I did the following:
>
>                 sed '/Pattern/, $d' OldFile > NewFile
>
> Which almost works perfectly!  The only problem is that sed omits the
> Pattern along with the lines that follow it.  I want it to omit only
> everything after Pattern, so the resulting file ends with Pattern.
>
> I've done about 15 minutes of looking on a website but cannot get
> any  syntax to work.
>
> Thanks in advance for anymore help,
>
> Ben
>
> _______________________________________________
> X-Unix mailing list
> X-Unix at listserver.themacintoshguy.com
> http://listserver.themacintoshguy.com/mailman/listinfo/x-unix
>
> Listmom is trying to clean out his closets! Vintage Mac and random stuff:
>          http://search.ebay.com/_W0QQsassZmacguy1984
>


--
Wing Wong
wingedpower at gmail.com


More information about the X-Unix mailing list