[H-GEN] one for an awk guru
Michael Dooley
m.dooley at mailbox.uq.edu.au
Wed Feb 4 14:42:00 EST 1998
Hi All,
Here's something strange I've seen with awk and nawk a
couple of time now. In this case I'm finding lines from headers of
files where $1 is SSBOND and creating an array of $4's and $6's. Here's
some sample lines:
SSBOND 1 CYS 9 CYS 47
1IGL 366
SSBOND 2 CYS 21 CYS 60
1IGL 367
SSBOND 3 CYS 46 CYS 51
1IGL 368
This is the script I've written:
nawk ' BEGIN {i=1;m=1}
$1 ~ /SSBOND/{cysteine[i] = $4;i++;cysteine[i] = $6;i++}
END {for (m in cysteine)
printf "%s\n",cysteine[m]}
' $1
Strangely, instead of the output:
9
47
21
60
46
51
I get:
47
21
60
46
51
9
If I use the alternative 'for' definition : for (m=1;m<=x;m++), I get
the output I want. However x will vary from file to file so I'd rather
use the array specification of for.
Is this a case of the script giving me what I ask for, not what I want
(??!!) any ideas?
Cheers
Michael
--
Michael Dooley PhD
Centre for Drug Design and Development
The University of Queensland
Brisbane Qld 4072 Australia
m.dooley at mailbox.uq.edu.au
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.humbug.org.au/pipermail/general/attachments/19980204/cc58b697/attachment.html>
More information about the General
mailing list