You're replying to a comment by simpleton.

simpleton Permalink
September 30, 2008, 19:10

Yep, you are right, mine won't work because of IP address length problems.

A corrected version using grep and cut is ~45 characters.

ifconfig|grep t\ a|cut -d" " -f12|cut -d: -f2

I still think you aren't counting right though. Please count the characters in:

ifconfig|perl -nE'/dr:(\S+)/&&say$1'

by hand, and you will get 36.

See:

[x@x ~]# ifconfig|perl -nE'/dr:(\S+)/&&say$1'
[x@x ~]# 123456789012345678901234567890123456

Compare:

[x@x ~]$ echo -n "ifconfig|perl -nE'/dr:(\S+)/&&say$1'" | wc -c
34
[x@x ~]$ echo -n "ifconfig|perl -nE'/dr:(\S+)/&&say'" | wc -c
34

"$1" is getting expanded to nothing, and you lose those characters in the count.

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 "sandbox": (just to make sure you're a human)

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