You're viewing a comment by Poil and its responses.

October 03, 2011, 09:53

:D

time ifconfig eth0 | awk  '/inet adr:/ { print substr($2,5,length($2)) }'
#real   0m0.009s
#user   0m0.001s
#sys    0m0.010s
time ifconfig eth0 | grep 'inet adr:' | cut -d: -f2 | awk '{ print $1}'
#real   0m0.014s
#user   0m0.003s
#sys    0m0.017s
time TOTO=$(ifconfig eth0); TOTO=${TOTO##*adr\:}; TOTO=${TOTO%% *}
#real   0m0.007s
#user   0m0.002s
#sys    0m0.004s
time ifconfig eth0 | sed '/inet\ /!d;s/.*r://g;s/\ .*//g'
#real   0m0.008s
#user   0m0.001s
#sys    0m0.009s
time ip addr show eth0 | grep -Po '\d+\.\d+\.\d+\.\d+\/\d+' | cut -d '/' -f 1
#real   0m0.009s
#user   0m0.002s
#sys    0m0.011s
time ip addr show eth0 | awk '/inet/ { print substr($2,0,length($2)-3) }'
#real   0m0.007s
#user   0m0.001s
#sys    0m0.009s
time TOTO=$(ip addr show eth0); TOTO=${TOTO##*inet}; TOTO=${TOTO%%/*}; echo $TOTO
#real   0m0.005s
#user   0m0.002s
#sys    0m0.004s
time ifconfig eth0|perl -nE'/dr:(\S+)/&&say$1'
#real   0m0.013s
#user   0m0.005s
#sys    0m0.012s
time ifconfig eth0|perl -nE'/dr:(\S+)/&&say$1'
#real   0m0.013s
#user   0m0.005s
#sys    0m0.012s
time ip addr show eth0|perl -nE'/inet (\S+)\// && say $1'
#real   0m0.013s
#user   0m0.005s
#sys    0m0.011s

Reply To This Comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the word "linux_90": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.