T o n g wrote:
> Bob Proulx wrote:
> >> . . . how to get *only* the IP address of my current
> >> Intranet address 192.168...?
>
> Thanks for your answer Bob,
>
> > Or if you don't like loopback addresses showing up in the list:
> >
> > $ ip addr show | awk '/ inet / && !/127\./{print$2}'
>
> and I don't like the "/24" that follows the IP address. so I made a small
> tweak based on your solution:
>
> ip -f inet addr | awk '/ inet / && !/127\./{sub(/\/.*/, "", $2); print
> $2}'
And I spotted a problem with the scraping out of 127. addresses. It
would also match 192.127.1.1 as a common sub-string. That was sloppy
of me. It should probably anchor on the "inet" part.
ip -f inet addr | awk '/ inet / && !/inet 127\./{sub(/\/.*/, "", $2); print $2}'
Curious. Why are you adding the family restriction with "-f inet"?
The future will definitely IPv6, even if I also scraped those out.
Bob
Attachment:
signature.asc
Description: Digital signature