You could do it by extracting it from the config file for the interface.
e.g. for RH/FC:
Code:
grep IPADDR /etc/sysconfig/network-scripts/ifcfg-eth0 |awk -F= '{print $2}'
You dismissed ifconfig for some reason. I don't know of a command that will give you just the IP. I wonder if you're aware you can do ifconfig by interface so you only have to parse from the specific interface you're interested in:
Code:
ifconfig eth0 |grep "inet addr" |awk '{print $2}' |awk -F: '{print $2}'
So far as making a single command you could easily do it with a script:
Code:
#!/bin/bash
IFACE=$1
ifconfig $IFACE |grep "inet addr" |awk '{print $2}' |awk -F: '{print $2}'
You just name the above script "getip" and put execute permission on it with chmod. You can then do your "getip eth0" using this script. A side benefit is if you don't put eth0 or another interface at command line (i.e. just type "getip") it will show the IPs for all active interfaces including lo0 (127.0.0.1).