George McNeal on Sat, 18 Sep 1999 22:40:05 -0400 (EDT)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Plug] Bash script


I want to write a script that parses the local eth0 IP address out of /sbin/ifconfig and assigns the value to a variable (loceth0) and later use $loceth0 as a value.  The following executed on a command line gives the correct IP.:

/sbin/ifconfig | grep -A 4 eth0 | awk ' /inet/ { print $2 } ' | sed -e s/addr://

However, if I write

loceth0='/sbin/ifconfig | grep -A 4 eth0 | awk ' /inet/ { print $2 } ' sed -e s/addr:// '

I get errors.  I am using the Bash shell.  What is the correct syntact or is there another route?