I would like to parse log files, I need to get only last IP from one or many divided by comma on beginning of the line:

This is how the lines look like:

```
80.250.5.1 - - [26/Oct/2010:13:10:14 +0200] ...
80.250.5.1, 80.250.5.2 somethingA - [26/Oct/2010:13:10:14 +0200] ...
80.250.5.1, 80.250.5.2, 80.250.5.3 - somethingB [26/Oct/2010:13:10:14 +0200] ...

```

I need to get:

```
80.250.5.1 - - [26/Oct/2010:13:10:14 +0200] ...
80.250.5.2 somethingA - [26/Oct/2010:13:10:14 +0200] ...
80.250.5.3 - somethingB [26/Oct/2010:13:10:14 +0200] ...

```

**Note:** There is never comma in somethingA and somethingB columns, this my help. There may be more commas in next columns after the [date].

I have tried to test few first columns and delete them if there is comma in it, but the problem is that sometimes there are more than 10 IPs there.

This works for 2 IPs:

```
awk '{if ($1 ~ /,/) {$1=""}; if ($2 ~ /,/) {$2=""}  }1'

```

My idea is to do something like "if there is comma before [, delete everything before comma, otherwise keep it unchanged". Unfortunately, my sed/awk skills are not good enough to do this.

Thanks a lot for any help.