lundi 8 février 2021

Use of if command in awk

When I run this command:

awk '{  if(substr($1,6,2)=="09") { print "Sep";}   }' myfile.log

results appear on the screen.

But if I run:

awk '{ print $2 "--"   if(substr($1,6,2)=="09") { print "Sep";}   }' myfile.log

I receive:

awk: line 1: syntax error at or near if

awk: line 1: syntax error at or near }

why?

Aucun commentaire:

Enregistrer un commentaire