Reputation: 33
I am writing a script which includes a function to list all interfaces EXCEPT loopback from ifconfig. The logic I'm using is to look for the loopback block by a regular expression and negating it. The command i use is ifconfig|awk '!/lo:/,/\n\n+/'
but this is still returning all the interfaces. When i remove the !
, only the loopback address is returned. Then why is the earlier command returning everything instead of everything except loopback?
Upvotes: 0
Views: 199
Reputation: 14949
You can use this awk
:
ifconfig | awk 'BEGIN{ORS=RS="\n\n"} !/^lo/{print}'
Upvotes: 3