Code Comments
Programming Forum and web based access to our favorite programming groups.I can't figure out how to format the individual output fields of an
array in the following short awk script:
( NR < 8 ) || ( $7 < 6 ) || ( $11 < 0.0 ) {
next
}
s7 && ( $7 != s7 ) {
V[++n] = FILENAME OFS $7 OFS c10 OFS V11 OFS $11
} {
s7 = $7; c10 = $10; V11 = $11
} END {
for ( i = 1; i <= n; i++ ) print V[i]
}
using the printf() function... The first field is clearly a string,
the others are variously formatted numbers.
z.entropic
Post Follow-up to this message
On 3/31/2008 7:40 AM, z.entropic wrote:
> I can't figure out how to format the individual output fields of an
> array in the following short awk script:
>
> ( NR < 8 ) || ( $7 < 6 ) || ( $11 < 0.0 ) {
> next
> }
> s7 && ( $7 != s7 ) {
> V[++n] = FILENAME OFS $7 OFS c10 OFS V11 OFS $11
> } {
> s7 = $7; c10 = $10; V11 = $11
> } END {
> for ( i = 1; i <= n; i++ ) print V[i]
> }
>
> using the printf() function... The first field is clearly a string,
> the others are variously formatted numbers.
It's not clear what you're asking for. Provide some small sample input and t
he
expected output for that input.
Ed.
Post Follow-up to this messagez.entropic wrote:
> I can't figure out how to format the individual output fields of an
> array in the following short awk script:
>
> ( NR < 8 ) || ( $7 < 6 ) || ( $11 < 0.0 ) {
> next
> }
> s7 && ( $7 != s7 ) {
> V[++n] = FILENAME OFS $7 OFS c10 OFS V11 OFS $11
Store them formatted here:
V[++n] = sprintf( ... )
Or store each value individually
V[++n,1] = FILENAME
V[n, 2] = $7
V[n, 3] = c10
...
and format them in END
/Thomas
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.