I want to split up a variable using awk by a colon, but only the last variable.
From this input:
 ACCEPT     tcp  --  0.0.0.0/0     0.0.0.0/0     tcp dpt:22
I want the following output:
 protocol=tcp source=0.0.0.0/0 destination=0.0.0.0/0 port=22
This is my awk command now:
 awk '/^ACCEPT/ {print "protocol=",$2, "source=",$4,"destination=",$5,"port=",$7}"
Which produces:
protocol=tcp source=0.0.0.0/0 destination=0.0.0.0/0 port=dpt:22
But I want to get 22 out of $7 and not dpt:22
I've tried using awk's field separator, but I can figure out how to make it only apply to a single variable
 
     
     
     
     
     
    