[CentOS] Define an alias with an embeded awk command

Tue Dec 15 15:35:24 UTC 2009
Bart Schaefer <barton.schaefer at gmail.com>

On Mon, Dec 14, 2009 at 8:54 PM, Andrew Harley <andrew at promed.com.au> wrote:
>
> It's not an issue with awk but with the way the alias is interpreted. It
> tries to run the result of the commands in between the ` ` as a command
> itself. To get around it, try:
>
> # alias checketh0="echo `ifconfig eth0 | grep 'inet addr:' |awk '{print $2}' | cut -c 6-`"

Er, no, the double quotes will mean that the backtick command is
expanded at the time the alias is defined rather than at the time it
is run.  So you'll get the ifconfig output from the time the shell
started, always.

You want

alias checketh0 'echo `ifconfig eth0 | grep "inet addr:" |awk
'\''{print $2}'\'' | cut -c 6-`'