0

My script doesn't work. Variable $Node doesn't work. Please check below error.

Nodes=(SV41)
for Node in $Nodes
do
  NPAG1RESUCC=$((cat $logfile |awk '/$Node/{c=38} c-->0' | awk '/NPAG1RESUCC/{print $2}'))
done

Result error:

((cat ~/test.log |awk '/SV41/{c=38} c-->0' | awk '/NPAG1RESUCC/{print }')):division by 0 (error token is "~/test.log |awk '/SV41/{c=38} c-->0' | awk '/NPAG1RESUCC/{print }'))")
Biffen
  • 6,249
  • 6
  • 28
  • 36
  • 1
    Your code has many additional errors. Maybe try http://shellcheck.net/ to get most of them fixed. It's not clear what you expect the first Awk script to produce, and generally you should get rid of at least one layer of parentheses. – tripleee Apr 12 '18 at 08:28
  • Perhaps something like `for Node in 'SV41'; do awk -v node="$Node" '$0 ~ node /{c=38}; c-->0 && /NPAG1RESUCC/ { print $2 }' "$logfile"; done` – tripleee Apr 12 '18 at 08:31

0 Answers0