[CentOS] Define an alias with an embeded awk command
Dave
tdbtdb+centos at gmail.com
Tue Dec 15 19:23:47 UTC 2009
On Mon, Dec 14, 2009 at 7:20 PM, Majian <jiannma at gmail.com> 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
More information about the CentOS
mailing list