Re: Define an alias with an embeded awk command

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



On Mon, Dec 14, 2009 at 8:54 PM, Andrew Harley <andrew@xxxxxxxxxxxxx> 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-`'
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux