Question: I know this is possible, probably by using `awk`, but I can't think the solution for now.

How do I convert IP format from

```none
10.1.1.1-10.1.1.3
10.100.100.11-10.100.100.31

```

to

```none
10.1.1.1-3
10.100.100.11-31

```

Here is my attempt with `cut`, but didn't really work as expected.

```none
wolf@linux:~$ echo 10.1.1.1-10.1.1.3 | cut -d . -f 1,2,3,4
10.1.1.1-10
wolf@linux:~$ 

wolf@linux:~$ echo 10.100.100.11-10.100.100.31 | cut -d . -f 1,2,3,4
10.100.100.11-10
wolf@linux:~$ 

```

Answer: 
Here's a `sed` approach. It will look for everything up to the last `-` on the line, save that as `\1`, then save the last occurrence of a `.` followed by one or more digits as `\2`. The entire line is then replaced by `\1\2`:

```
$ sed -E 's/(.*-).*\.([0-9]+)/\1\2/' file 
10.1.1.1-3
10.100.100.11-31

```

Alternatively, in `awk`, you could set the input field separator to `.` or `-`, and the output field separator to `.`, and then print the frist through fourth fields, a `-` and the last field:

```
$ awk -F'[-.]' -vOFS="." '{print $1,$2,$3,$4"-"$NF}' file 
10.1.1.1-3
10.100.100.11-31

```
```
$ sed 's/-.*\./-/' file
10.1.1.1-3
10.100.100.11-31

```