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 7:20 PM, Majian <jiannma@xxxxxxxxx> wrote:
> But After  I  edit the command "alias checketh0  "echo `ifconfig eth0 | grep
> 'inet addr:' |awk '{print $2}' | cut -c 6-`"  in my .cshrc file
> The screen displays this :
> innet addr:192.168.7.24 Bcast:192.168.7.255 Mask :255.255.255.0

I think you need to escape either the {} or $ in the awk command, or
else not use it. Try:

[root@ ~]# alias  checketh0 "ifconfig eth0 | grep 'inet addr:'|cut -d
':' -f 2|cut -f 1 -d ' '"
[root@ ~]# checketh0
12.17.152.3

Note that I did not use any '`' marks. The example is on the command
line, not in .cshrc, but I hope it will work in that context anyhow.

This is a bit OT, should probably have OT in the subject?

HTH!
Dave
_______________________________________________
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