I am trying to get the total length of each matching string and the count of each match in a file using `awk`. The matching string in `$5` is the count and the sum of each `$3 - $2` is the total length. Hopefully the `awk` below is a good start. Thank you :).

**input**

```
chr1 1266716 1266926 chr1:1266716-1266926 TAS1R3
chr1 1267008 1267328 chr1:1267008-1267328 TAS1R3
chr1 1267394 1268196 chr1:1267394-1268196 TAS1R3
chr1 1268291 1268514 chr1:1268291-1268514 TAS1R3
chr1 1956371 1956503 chr1:1956371-1956503 GABRD
chr1 1956747 1956866 chr1:1956747-1956866 GABRD
chr1 1956947 1957187 chr1:1956947-1957187 GABRD
chr1 1220077 1220196 chr1:1220077-1220196 SCNN1D

```

**desired output**

```
TAS1R3 4 1555
GABRD 3 491
SCNN1D 1 119

```

**awk**

```
awk '{count[$5]++}
END {
  for (word in count)
    print $1,$2,$3,$4,word, count[word]
}' input > count | 
awk 'print $1,$2,$3,$4,word, count[word]
}
{ $6 = $3 - $2 }
1' count.txt > length

```

**edit**

```
SCNN1D 1 119
GABRD 3 240
TAS1R3 4 223 

```