Thanks for your advice ~<br>But After I edit the command "alias checketh0 "echo `ifconfig eth0 | grep 'inet addr:' |awk '{print
$2}' | cut -c 6-`" in my .cshrc file <br>The screen displays this :<br>innet addr:192.168.7.24 Bcast:192.168.7.255 Mask :255.255.255.0<br><br>I just want to the "192.168.7.24"<br><br><br> Maybe is it the awk command error?<br>
<br><div class="gmail_quote">On Tue, Dec 15, 2009 at 12:54 PM, Andrew Harley <span dir="ltr"><<a href="mailto:andrew@promed.com.au">andrew@promed.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div text="#000000" bgcolor="#ffffff"><div><div></div><div class="h5">
On 15/12/09 15:40, Majian wrote:
<blockquote type="cite">Hi ,all :<br>
<br>
I'm trying to define an alias with an embeded awk command:<br>
<br>
alias checketh0 `ifconfig eth0 |grep 'inet addr:' |awk '{prinrt $2}'
|cut -c 6- `<br>
<br>
After I edit it in the .cshrc file and run "source .cshrc" , I run
the "checketh0" command in the terminal ,<br>
the screen displays the "<a href="http://192.168.7.24" target="_blank">192.168.7.24</a>: Command not found "<br>
<br>
<br>
Why does is it ?Any help will be highly appreciated.<br>
<br>
note: I'm using csh shell.<br>
</blockquote></div></div>
Hi Majian,<br>
<br>
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: <br>
<br>
# alias checketh0="echo `ifconfig eth0 | grep 'inet addr:' |awk '{print
$2}' | cut -c 6-`"<br>
<br>
Cheers,<br>
<br>
Andrew<br>
</div>
<br>_______________________________________________<br>
CentOS mailing list<br>
<a href="mailto:CentOS@centos.org">CentOS@centos.org</a><br>
<a href="http://lists.centos.org/mailman/listinfo/centos" target="_blank">http://lists.centos.org/mailman/listinfo/centos</a><br>
<br></blockquote></div><br>