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: 
An option with `awk`:

```
awk -F'[.-]' '{ print $1"."$2"."$3"."$4"-"$8 }'

```

Output:

```
10.1.1.1-3
10.100.100.11-31

```
```
LC_ALL=C sed 's/^\([0-9.]*\.\)\([0-9]\{1,\}-\)\1\([0-9]\{1,\}\)$/\1\2\3/'

```

Would give the expected output for lines that are in the `anything.digits-anything.digits` and leave the lines that don't match that pattern (like `1.2.3.4-1.2.6.254`) alone.