regexp lazy match

eiguleo

Cook

Posted on June 12, 2024

regexp lazy match

case

demo string is
/sbin/dhclient /xx -4 -d -nw -cf /run/dhclient/dhclient_eth1.conf -pf /run/dhclient/dhclient_eth1.pid

target

/run/dhclient/ is prefix path, it would change as os version changes, so get the /run/dhclient/

code

echo "/sbin/dhclient /xx -4 -d -nw -cf /run/dhclient/dhclient_eth1.conf -pf /run/dhclient/dhclient_eth1.pid" | grep -P "/\S*?eth1.conf " --color

resp

/run/dhclient/dhclient_eth1.conf

💖 💪 🙅 🚩
eiguleo
Cook

Posted on June 12, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related