[CentOS] Define an alias with an embeded awk command
Les Mikesell
lesmikesell at gmail.com
Tue Dec 15 20:44:48 UTC 2009
m.roth at 5-cent.us wrote:
>
> Simpler, and more obvious to read:
>
> /sbin/ifconfig eth0 | awk '{if ( $0 ~ /inet addr:/ ) {print substr($2,6)}}'
That's only obvious to the couple of people who speak awk... (Probably
about the same number that use the C shell that started this problem).
With more generic regexps it would be:
ifconfig eth0 |sed -n -e 's/\(.*inet addr:\)\([0-9.]*\)\(.*\)/\2/p'
--
Les Mikesell
lesmikesell at gmail.com
More information about the CentOS
mailing list