Question: Have a file with below pattern

```
a 12
a 13
a 15
a 14
b 5
b 6
c 2
c 5

```

I'd like to group these according to the first column, like below

```
a 12 13 15 14
b 5 6
c 2 5

```

Please suggest

Answer: 
Assuming that the data is sorted by the first column, as it is in the question, using GNU `datamash` to group by the first whitespace-delimited column and collapse the second.

```bsh
$ datamash -W groupby 1 collapse 2 <file
a       12,13,15,14
b       5,6
c       2,5

```

Replacing the tab after the first column in the result as well as the commas, by spaces, to arrive at the wanted output:

```bsh
$ datamash -W groupby 1 collapse 2 <file | tr '\t,' '  '
a 12 13 15 14
b 5 6
c 2 5

```

If the input is not sorted by the first column, then pass the data through `sort` first, or use `datamash` with its `-s` (`--sort`) option.
Using `awk` (if the input file is sorted by the first column):

```
awk '{ printf "%s", (NR==1 || pre!=$1? (NR>1? ORS:"")$1: "") OFS $2; pre=$1 }
END  { print "" }' infile

```

Using `awk` +`sort` (if the input file is not sorted by the first column):

```
<infile sort|
    awk '{ printf "%s", (NR==1 || pre!=$1? (NR>1? ORS:"")$1: "") OFS $2; pre=$1 }
    END  { print "" }'

```

Or using only `awk` either for sorted input or unsorted:

```
awk '{ grp[$1]= (grp[$1]==""?"":grp[$1] OFS) $2 }
END  { for(x in grp) print x, grp[x] }' infile

```