I have the following log in my server. If we look at column 1, the entries could be a single IP address (117.199.183.116) or multiple Ip address (115.248.95.5, 115.112.231.105) Since space is the delimiter between the various entries in a line so using cut -d " " -f 1,10 to separate columns will give different results for line 1 and line 2. So can anyone tell me how to solve this problem of getting the exact result.
117.199.183.116 - [11/Dec/2013:23:00:29 -0600] "GET /promotions/getConfig/ HTTP/1.1" 200 2841 36 TLSv1 DHE-RSA-SEED-SHA
115.248.95.5, 115.112.231.105 - [11/Dec/2013:23:00:29 -0600] "GET /promotions/getConfig/ HTTP/1.1" 200 3142 36 TLSv1 DHE-RSA-SEED-SHA
182.243.43.29 - [11/Dec/2013:23:00:29 -0600] "GET /promotions/getConfig/ HTTP/1.1" 200 3124 36 TLSv1 DHE-RSA-SEED-SHA
182.127.213.39 - [11/Dec/2013:23:00:29 -0600] "GET /promotions/getConfig/ HTTP/1.1" 200 2933 36 TLSv1 DHE-RSA-SEED-SHA
The expected output is:
117.199.183.116 36
115.248.95.5, 115.112.231.105 36
182.243.43.29 36
1182.127.213.39 36
To be more exact the log entries are something like
222.86.58.126 - [17/Dec/2013:08:21:40 -0600] "GET /promotions/getConfig/ HTTP/1.1" 200 1505 36 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"i TLSv1.2 DHE-RSA-SEED-SHA
218.95.69.175, 22.234.234.12 - [17/Dec/2013:08:21:40 -0600] "GET /promotions/getConfig/ HTTP/1.1" 200 1477 36 "http://www.duba.com/static/js/storage/storage.swf?v=2&fun=swfStorage._init" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"i TLSv1.2 DHE-RSA-SEED-SHA
So can there be a more generic solution so that we can pick any two columns.