Reputation: 300
for INSTANCE in $INSTANCES
do
ssh weblogic@${SERVER} "egrep \"^$SEARCHHOUR1:$SEARCHMIN1.*DEBUG.*LONG QUERY.* ms.\$|^$SEARCHHOUR2:$SEARCHMIN2.*DEBUG.*LONG QUERY.* ms.\$\" vgprod1/mw.log.$INSTANCE | awk '{ $(NF-1)>=10000 }' "
done
Error:
NF-1: command not found
awk: cmd. line:1: { >=10000 }
awk: cmd. line:1: ^ syntax error
I am getting the above error while executing on a Unix server. I guess I am missing backslash at some places in AWK. How can I fix this?
Upvotes: 1
Views: 7707
Reputation: 47189
As noted by sarathi, your problem is an unquoted $
.
It might be easier to spot if you split up the command:
pattern="^$SEARCHHOUR1:$SEARCHMIN1.*DEBUG.*LONG QUERY.* ms.\$|^$SEARCHHOUR2:$SEARCHMIN2.*DEBUG.*LONG QUERY.* ms.\$"
for INSTANCE in $INSTANCES
do
ssh weblogic@${SERVER} "egrep '$pattern' vgprod1/mw.log.$INSTANCE | awk '\$(NF-1) > 1000'"
done
Also note that egrep '$pattern'
will be expanded correctly when it is enclosed in double quotes.
Upvotes: 1