I'm trying to get just the local IP of my Arch VM. I've managed to get just the line containing what I want with grep, but I also want to trim it down with sed.
inet <<192.168.0.16>>/24 brd 192.1680.255 scope global enp0s3 $ I want the IP in <<>> ip addr show | grep 'inet\ ' | sed -n -e 's/^.*inet\ (.*)\/.*$/\1/p' -n # print nothing by default s # replacement command ^ # begin line .* # anything inet\ # inet and then a space (.*) # capture anything \/ # end capture at the / that comes before 24 .* # anything $ # end \1 # replace all that with the first capture group which should be the IP p # print the output
But as soon as I add the sed, it gives me nothing. I assume something is wrong with my regex.