I have a NAT device that makes NAT logs like this:
Dec 13 18:12:59 172.16.1.1 "LSN_DELETE""192.168.100.1%101:11921""TCP""100.100.100.100%101:11921""104.111.224.226:80""1481639868477""327573"
I want to make a csv file by converting each line of this file to:
192.168.100.1,11921,TCP,100.100.100.100,11921,104.111.224.226,80,1481639868477,327573
I know that I can read the file line by line and convert it using cut command but reading file line by line is very slow and the file is very huge (5 million lines). I want to convert it by awk or sed that are more fast. could someone please help me to do that?
In awk, a partial solution (you'll have to add fields in the order you like):
gawk -F '[^.[:digit:][:alpha:]]*' -v OFS=, '{print $9,$15,$12}' file
That is, assuming the log is in the file named file
:
No guarantees that this will be faster than what you were doing before.