For Programmers: Free Programming Magazines  


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-06, 3:57 pm



Rookie Card wrote:

> Ed -
> awk '{ print substr($0,18,1) }' REC18.txt
> A
> B
> S
> A
>
> Then I try
> awk '{ print "A"==substr($0,18,1) }' REC18.txt
> 0
> 0
> 0
> 0
> This is with the example data: REC18.txt
> 20040911324834736A90028
> CLIENTID000VNI112B92658
> CLIENTID000VNI118S98271
> 20041112534129983A93065
> Thanks
> Gary / Rookie Card
>


Since neither oawk nor nawk would accept that last command, I assume
you're running gawk. Here's what happens when I use gawk version 3.0.4
on Solaris:

PS1> gawk '{ print substr($0,18,1) }' REC18.txt
A
B
S
A
PS1> gawk '{ print "A"==substr($0,18,1) }' REC18.txt
1
0
0
1

Regards,

Ed.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com