Hello,
I've been working on a bash script to parse through firewall logs (cisco). I'm nearing the end and have a dilemma.
My data looks as such (actual data is several gigs worth of logs - without the headers):
sourceIP destinationIP destinationProtocol destinationPort
1.1.1.1 2.2.2.2 TCP 22
1.1.1.1 2.2.2.2 TCP 31
1.1.1.1 2.2.2.2 TCP 45
1.1.1.1 2.2.2.2 TCP 67
1.1.1.3 2.2.2.2 TCP 22
1.1.1.3 2.2.2.2 TCP 89
1.1.1.3 2.2.2.2 TCP 78
1.1.1.1 2.2.2.3 TCP 78
1.1.1.1 2.2.2.3 TCP 79
I would like to script it so that the ports are put on a single line for matching IPs, like so:
sourceIP destinationIP destinationProtocol destinationPort
1.1.1.1 2.2.2.2 TCP 22, 31, 45, 67
1.1.1.3 2.2.2.2 TCP 22, 89, 78
1.1.1.1 2.2.2.3 TCP 78, 79
Would awk or sed be able to do what I'm looking for? How?
Any help would be much appreciated.