Home > Archive > AWK > January 2005 > Re: Fixed length records containing 2 different records types with
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: Fixed length records containing 2 different records types with
|
|
| Ed Morton 2005-01-12, 8:55 am |
|
Rookie Card wrote:
> I'm geting closer (this gawk 3.1.3 / MSDOS)
> I ran:
> gawk "{ print "A"=substr($0,18,$0)}" REC18.txt
The above is doing the following things wrong:
1) Passing a string as the third argument for substr()
2) Trying to assign the result of substsr() to a string
3) Not escaping the double-quotes within the script.
Try this:
gawk "{ print \"A\"==substr($0,18,1)}" REC18.txt
and next time please post what you're actually using!
Ed.
> Output was:
> A90028
>
> A93065
>
> It now filters correct but only prints the last 6 charactors
> Now I just need to figure out how to get it to print the whole record
> which in the awk lang is ($0) Right?
>
| |
| Kenny McCormack 2005-01-12, 8:55 am |
| In article <crk3gf$n83@netnews.proxy.lucent.com>,
Ed Morton <morton@lsupcaemnt.com> wrote:
>
>
>Rookie Card wrote:
>
>The above is doing the following things wrong:
>
>1) Passing a string as the third argument for substr()
Perfectly legal. The value of $0 is converted to an integer and used as
the length of the string to extract.
>2) Trying to assign the result of substsr() to a string
That's what I thought at first glance - and I assumed (correctly, as it
turns out) that GAWK (or any AWK, for that matter) would flag it as an
error. However, look beneath the surface.
In the crazy, mixed up world of MS command interpreters, this parses as:
{ print A=something }
which is perfectly legal.
>3) Not escaping the double-quotes within the script.
See above comments about the "crazy, mixed up world".
Nothing to do with AWK, of course.
|
|
|
|
|