root@debian:~# ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:00:09:4b
inet addr:192.168.22.126 Bcast:192.168.23.255 Mask:255.255.252.0
inet6 addr: fe80::a00:27ff:fe00:94b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:247726 errors:0 dropped:0 overruns:0 frame:0
TX packets:1150 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:26655160 (25.4 MiB) TX bytes:112805 (110.1 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2488 errors:0 dropped:0 overruns:0 frame:0
TX packets:2488 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:265796 (259.5 KiB) TX bytes:265796 (259.5 KiB)
root@debian:~# ifconfig | grep ‘inet addr:’
inet addr:192.168.22.126 Bcast:192.168.23.255 Mask:255.255.252.0
inet addr:127.0.0.1 Mask:255.0.0.0
root@debian:~# ifconfig | grep ‘inet addr:’| grep -v ‘127.0.0.*’
inet addr:192.168.22.126 Bcast:192.168.23.255 Mask:255.255.252.0
root@debian:~# ifconfig | grep ‘inet addr:’| grep -v ‘127.0.0.*’ | cut -d: -f2
192.168.22.126 Bcast
root@debian:~# ifconfig | grep 'inet addr:'| grep -v '127.0.0.*' | cut -d: -f2 | awk '{ print $1}'
192.168.22.126