emblem
Programmer
- Jun 25, 2002
- 26
Hi all:
I have an awk array which looks like this:
5
2
1
4
I.e, up to n values, where each n is a positive integer <= n
How can I tell that I am missing the value 3 ??
Here is my code:
fullcount_p=16
ps -ef|grep PSAPPSRV | egrep -v '(grep|RPSHR)'| /usr/xpg4/bin/awk -v fcp=$fullcount_p '{P_ary[NR] = $14}
END {if ( $NR -lt fcp )
{for (j = 0; j <(fcp - 1); j++)
{if ( P_ary[j] == '' )
print j
}
}
}
}'
This dies on the print j line, cause it treats the '' as a missing right-hand operand. What I need is an ISNULL statement. Here is the error message:
/usr/xpg4/bin/awk: file "[command line]": line 3: syntax error Context is:
>>> = 0; j <(fcp - 1); j++)
>>> {if ( P_ary[j] == ) <<<
I realize the egrep is lame, but my shell doesn't have a -e flag for grep.
I suspect that a workaround for my problem is to initialize an array with fullcount_p elements in BEGIN, then delete elements for every matching input, then print just the remaining elements in the END, but if you know how to identify null elements directly, that would be much appreciated!
I have an awk array which looks like this:
5
2
1
4
I.e, up to n values, where each n is a positive integer <= n
How can I tell that I am missing the value 3 ??
Here is my code:
fullcount_p=16
ps -ef|grep PSAPPSRV | egrep -v '(grep|RPSHR)'| /usr/xpg4/bin/awk -v fcp=$fullcount_p '{P_ary[NR] = $14}
END {if ( $NR -lt fcp )
{for (j = 0; j <(fcp - 1); j++)
{if ( P_ary[j] == '' )
print j
}
}
}
}'
This dies on the print j line, cause it treats the '' as a missing right-hand operand. What I need is an ISNULL statement. Here is the error message:
/usr/xpg4/bin/awk: file "[command line]": line 3: syntax error Context is:
>>> = 0; j <(fcp - 1); j++)
>>> {if ( P_ary[j] == ) <<<
I realize the egrep is lame, but my shell doesn't have a -e flag for grep.
I suspect that a workaround for my problem is to initialize an array with fullcount_p elements in BEGIN, then delete elements for every matching input, then print just the remaining elements in the END, but if you know how to identify null elements directly, that would be much appreciated!