1
I've created a script for awk. I'm combining loop "for" with "if" statement. It's searching each line for word "ABC" which can occure in different place in the line. It looks like below:
{for (i=1;i<=NF;i++) if ($i=="ABC") print $(i-2)}
The problem appears when there is no "ABC" in the line and I would like to print an information about it. With script as below it gaves me an information for each word from the line which is different than "ABC" and I would like ONLY ONE information for line (not for each word).
{for (i=1;i<=NF;i++) if ($i=="ABC") print $(i-2)
else if ($i=="ABC") print "no ABC in the line"}
Regards, lucas