My text file looks like below
date=\"2017-10-10\" ip=192.168.1.1:22 inbound=100 outbound=100
date=\"2017-10-10\" ip=192.168.1.1:22 inbound=100
date=\"2017-10-10
Whenever you have name=value pairs in your input it's best to first create an array of those mappings (f[]
below) and then you can just print (or do anything else with) the values by name:
$ awk -v n="inbound" -F'[ =]+' '{delete f; for (i=1;i
Want to do the same for "outbound" or any other field? Just init the name variable n
accordingly"
$ awk -v n="outbound" -F'[ =]+' '{delete f; for (i=1;i