I have a text file with lines like this (in Linux Bash):

```
A B C D
A B C J
E B C P
E F G N
E F G P
A B C Q
H F S L
G Y F Q
H F S L

```

I need to find the lines with unique values for the first 3 columns, print their count and then print summarized last column for each unique line, so the result is like this:

```
3 A B C D,J,Q
1 E B C P
2 E F G N,P
1 G Y F Q
2 H F S L

```

**What I have tried:**

```
cat FILE | sort -k1,3 | uniq -f3 -c | sort -k3,5nr

```

Is there maybe any advice?

Thanks in advance!