quoting,variable substitution and command substitution
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Shell > quoting,variable substitution and command substitution




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    quoting,variable substitution and command substitution  
hantechs@gmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-27-07 12:22 PM

I'm confused with the result of the following script:
cmd="echo abc | grep abc"
echo $($cmd)
it's output in my linux box is :
abc | grep abc
It seems that the command substitution treats the cmd's value as one
command unit(not two commands combined with '|') with arguments
separated by whitespace. Why? If it is because the quoting, I think it
should  treats the whole string as a command name, just as :
echo $("echo abc | grep abc")
Can somebody explain it? Thanks.






[ Post a follow-up to this message ]



    Re: quoting,variable substitution and command substitution  
Bruce Barnett


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-28-07 12:21 AM

"hantechs@gmail.com" <hantechs@gmail.com> writes:

> I'm confused with the result of the following script:
> cmd="echo abc | grep abc"

[snip]

> It seems that the command substitution treats the cmd's value as one
> command unit

You didn't use command substitution. You used simple (weak) quotes.

Change " to `



--
Sending unsolicited commercial e-mail to this account incurs a fee of
$500 per message, and acknowledges the legality of this contract.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:37 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register