I’m trying to filter IP addresses from the ip a
command via sed
. When I write inet6*
it works. When I write inet6?
it doesn’t find the match.
With *
:
$ ip a | sed -ne 's,^ *inet6* ([^ /]*).*$,1,p'
05:06:33
127.0.0.1
::1
192.168.43.222
fe80::df04:ee5d:a05f:ba1
With ?
:
$ ip a | sed -ne 's,^ *inet6? ([^ /]*).*$,1,p'
05:07:39
When I try to run with +
instead of *
it doesn’t work either:
$ ip a | sed -ne 's,^ *inet6* ([^ /]+).*$,1,p'
05:35:21
Does sed work with ?
or +
? Or does it only work with *
?