[KLUG Members] bash builtin substr function

Bruce Smith bruce at armintl.com
Thu May 5 16:14:24 EDT 2005


> Here is what I have so far...
> 
> #!/bin/bash
> 
> IPADDR=`ifconfig -a eth0 | grep "inet addr"`
> 
> echo ${IPADDR#"inet addr:"*" "}


IPADDR=`ifconfig -a eth0 | grep "inet addr"`
IPADDR2=${IPADDR#*:}
IPADDR=${IPADDR2%% *}
echo $IPADDR


Just one way to do it.  Let me know if you want to see others.  :-)]

 - BS




More information about the Members mailing list