regexp lazy match
Cook
Posted on June 12, 2024
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
💖 💪 🙅 🚩
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
webdev Understanding HTTP, Cookies, Email Protocols, and DNS: A Guide to Key Internet Technologies
November 30, 2024