While looking for a way to have a #Bash get the main #IPv4 address of an interface I came upon this solution:

ip -f inet addr show enp1s0 | grep --color=NO -Po 'inet \K[\d.]+'

This raised the question: WT(U+2131) does \K in a (-Perl style) #regex?

It turned out to be an alternative in #Perl for a look-ahead match:

~$ echo 'hello world' | grep -oP 'hello \K(world)'
world
~$ echo 'hello world' | grep -oP 'hello (world)'
hello world

There are no comments yet.