I'm having a problem regarding the if statement with regex inside the awk. What im trying to do is that, if there is a letter i in the $NF it would print out as Incoming, and if there's a letter o in the $NF value it will display the Outgoing.
Below is the command i'm trying to construct
awk -F"/" -v var""'{ if ($NF =~ .*i) then var="Incoming" print $8 ";" $NF ";" var elif ($NF =~ .*o) print $8 ";" $NF ";" var }'
i always get the error
awk: cmd. line:1: { if ( $NF =~ ".*i" ) {print $8 ";" $NF "; Incoming"} else print $8 ";" $NF "; Outgoing" fi }
awk: cmd. line:1: ^ syntax error
awk: cmd. line:1: { if ( $NF =~ ".*i" ) {print $8 ";" $NF "; Incoming"} else print $8 ";" $NF "; Outgoing" fi }
awk: cmd. line:1: ^ syntax error
can anyone help me with this ?
Aucun commentaire:
Enregistrer un commentaire