Hi. I am trying to split an ASCII file on the page break character,
w/o success. If I run "awk searchstring filename" then on stdout the
lines listing the searchstring appear. I tried re-setting the RS
variable, but didn't get the expected results. When I tried "awk
`RS=??` searchstring filename" where ?? was 0x0C, ^M, \f and a few
others, I either recieved no output, or the entire file.
I also triedv "awk '/^M$/ && on == 1 {exit} on == 1 {print} /^M$/
{on=1}' searchstring filename" with similar results.
Could someone please help. The end goal is to read in the file,
search for the string, and only print out the page(s) containing the
searchstring.
Thanks
Kevin
|
|
0
|
|
|
|
Reply
|
kefraser
|
8/18/2003 9:19:45 PM |
|
isn't that RS should be either a character or a regular expression?
so... maybe something like /[yourcharacters]/ could do...
i don't know... please have a try
cheers
sandr8
On 18 Aug 2003 14:19:45 -0700
kefraser@rocketmail.com (Kevin) wrote:
> Hi. I am trying to split an ASCII file on the page break character,
> w/o success. If I run "awk searchstring filename" then on stdout the
> lines listing the searchstring appear. I tried re-setting the RS
> variable, but didn't get the expected results. When I tried "awk
> `RS=??` searchstring filename" where ?? was 0x0C, ^M, \f and a few
> others, I either recieved no output, or the entire file.
>
> I also triedv "awk '/^M$/ && on == 1 {exit} on == 1 {print} /^M$/
> {on=1}' searchstring filename" with similar results.
>
> Could someone please help. The end goal is to read in the file,
> search for the string, and only print out the page(s) containing the
> searchstring.
>
> Thanks
> Kevin
|
|
0
|
|
|
|
Reply
|
Alessandro
|
8/18/2003 9:32:50 PM
|
|
gazelle@yin.interaccess.com (Kenny McCormack) wrote in message news:<bhrgu1$f66$1@yin.interaccess.com>...
> In article <fc977839.0308181319.15bcb05e@posting.google.com>,
> Kevin <kefraser@rocketmail.com> wrote:
> >Hi. I am trying to split an ASCII file on the page break character,
> >w/o success. If I run "awk searchstring filename" then on stdout the
> >lines listing the searchstring appear. I tried re-setting the RS
> >variable, but didn't get the expected results. When I tried "awk
> >`RS=??` searchstring filename" where ?? was 0x0C, ^M, \f and a few
> >others, I either recieved no output, or the entire file.
> >
> >I also triedv "awk '/^M$/ && on == 1 {exit} on == 1 {print} /^M$/
> >{on=1}' searchstring filename" with similar results.
> >
> >Could someone please help. The end goal is to read in the file,
> >search for the string, and only print out the page(s) containing the
> >searchstring.
>
> It should work. I just tested, and got predictable results, with the
> following two scripts:
>
> # First, write a script to create a test file:
> #!/bin/gawk -f
> BEGIN {
> for (i=1; i<=100; i++)
> print "Line:",i,i % 10 ? "" : "\f"
> }
>
> # Run that file, redirecting output to /tmp/foo
> # Now, run a test on that file:
> % gawk 'BEGIN {RS="\f"} /77/' /tmp/foo
>
> produces output of:
>
> Line: 71
> Line: 72
> Line: 73
> Line: 74
> Line: 75
> Line: 76
> Line: 77
> Line: 78
> Line: 79
> Line: 80
Thanks. This was exactly what I was looking for.
|
|
0
|
|
|
|
Reply
|
kefraser
|
8/20/2003 3:16:28 PM
|
|
|
2 Replies
385 Views
(page loaded in 0.044 seconds)
|