Sample data

```
wolf@linux:~$ cat data.csv 
A,4.4.4.4,4.4.4.5,4.4.4.6,3.3.3.3,3.3.3.4
B,1.1.1.1,1.1.1.1,1.1.1.2,1.1.1.3,3.3.3.3
C,1.1.1.1,1.1.1.1,1.1.1.1,1.1.1.1,1.1.1.1
D,2.2.2.1,2.2.2.1,2.2.2.2,2.2.2.3,2.2.2.4
wolf@linux:~$ 

```

There are a few duplicate data in this sample. e.g. there are two `3.3.3.3` which located in row A and row B.

```
wolf@linux:~$ egrep 3.3.3.3 data.csv 
A,4.4.4.4,4.4.4.5,4.4.4.6,3.3.3.3,3.3.3.4
B,1.1.1.1,1.1.1.1,1.1.1.2,1.1.1.3,3.3.3.3
wolf@linux:~$ 

```

Right now I'm only interested with the 1st column which are `A,B,C,D` and also the related data.

Here is 4 data that I need to find.

```
2.2.2.3
3.3.3.3
4.4.4.4
5.5.5.5

```

So, I use `|` and `-o` in egrep

```
wolf@linux:~$ egrep '2.2.2.3|3.3.3.3|4.4.4.4|5.5.5.5' data.csv
A,4.4.4.4,4.4.4.5,4.4.4.6,3.3.3.3,3.3.3.4
B,1.1.1.1,1.1.1.1,1.1.1.2,1.1.1.3,3.3.3.3
D,2.2.2.1,2.2.2.1,2.2.2.2,2.2.2.3,2.2.2.4
wolf@linux:~$ 

```

The output is good, but there is too much data in it. I just want the related data and the 1st column.

So, here is another attempt with `-o`

```
wolf@linux:~$ egrep -o '2.2.2.3|3.3.3.3|4.4.4.4|5.5.5.5' data.csv
4.4.4.4
3.3.3.3
3,3.3.3
2.2.2.3
wolf@linux:~$ 

```

The problem now I can't get the 1st column (`A/B/C/D`) with this

Next attempt

```
wolf@linux:~$ egrep '2.2.2.3|3.3.3.3|4.4.4.4|5.5.5.5' data.csv | cut -d , -f 1
A
B
D
wolf@linux:~$

```

I get the 1st column, but not the data. By looking at the output, I've no idea `A` represents both `3.3.3.3` and `4.4.4.4` as it's not being displayed on the output.

That's not really the output that I wanted. What I have in mind right now is something like this

**Desired Output**

Input

```
2.2.2.3
3.3.3.3
4.4.4.4
5.5.5.5

```

Output

```
D       2.2.2.3   
A,B     3.3.3.3
A       4.4.4.4
-       5.5.5.5

```

Unfortunately, I just can't think the solution for now. Please help