I want to split the variable using awk into a colon, but only into the last variable.
From this input:
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
I need the following output:
protocol=tcp source=0.0.0.0/0 destination=0.0.0.0/0 port=22
Now this is my awk command:
awk '/^ACCEPT/ {print "protocol=",$2, "source=",$4,"destination=",$5,"port=",$7}"
What 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 $7
, notdpt:22
I tried using awk field delimiter but can figure out how to make it apply to only one variable
source
share