unix variable meaning (might be echo)
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 questions > unix variable meaning (might be echo)




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

    unix variable meaning (might be echo)  
siddharthkrish@gmail.com


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


 
01-14-06 03:40 AM

hi everyone,

can someone tell me what this means? i know what it does but i don't
understand why

VARIABLE = "something sometime"

echo ${VARIABLE#something}

output:
sometime

but what's this supposed to mean?

~ Krish






[ Post a follow-up to this message ]



    Re: unix variable meaning (might be echo)  
Ed Morton


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


 
01-14-06 03:40 AM

siddharthkrish@gmail.com wrote:
> hi everyone,
>
> can someone tell me what this means? i know what it does but i don't
> understand why
>
> VARIABLE = "something sometime"
>
> echo ${VARIABLE#something}
>
> output:
>  sometime
>
> but what's this supposed to mean?
>
> ~ Krish
>

Look up "parameter substitution" in your shell man page.

Ed.





[ Post a follow-up to this message ]



    Re: unix variable meaning (might be echo)  
Sashi


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


 
01-14-06 03:40 AM


Ed Morton wrote:
> siddharthkrish@gmail.com wrote: 
>
> Look up "parameter substitution" in your shell man page.
>
> 	Ed.
This is useful for string concatenation.
For example, echo $VARIABLE  in your case will print "something
sometime".
What if you want to print "something sometimenow"?
echo $VARIABLEnow won't work as the shell will go looking for a new
variable VARIABLEnow  and will end up printing nothing, as this var has
not been initialized.
echo $VARIABLE now will add an extra space between sometime and now.
echo ${VARIABLE}now  will print what you want: string concatenation
with no spaces in between. This works due to shell expansion ONLY for
VARIABLE.
As for echo ${VARIABLE#something}, a wiser head than mine should
answer.
Sashi






[ Post a follow-up to this message ]



    Re: unix variable meaning (might be echo)  
Kevin Collins


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


 
01-14-06 03:40 AM

In article <1136895825.680529.120100@g14g2000cwa.googlegroups.com>,
siddharthkrish@gmail.com wrote:
> hi everyone,
>
> can someone tell me what this means? i know what it does but i don't
> understand why
>
> VARIABLE = "something sometime"

This in not valid, although the below would be:

VARIABLE="something sometime"

> echo ${VARIABLE#something}
>
> output:
>  sometime
>
> but what's this supposed to mean?

Others have already answered the question...

Kevin

--
Unix Guy Consulting, LLC
Unix and Linux Automation, Shell, PERL and CGI scripting
http://www.unix-guy.com





[ Post a follow-up to this message ]



    Re: unix variable meaning (might be echo)  
Sashi


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


 
01-14-06 03:40 AM


Kevin Collins wrote:
> In article <1136895825.680529.120100@g14g2000cwa.googlegroups.com>,
> siddharthkrish@gmail.com wrote: 
>
> This in not valid, although the below would be:
>
>  VARIABLE="something sometime"
> 
>
> Others have already answered the question...
>
> Kevin
>
> --
> Unix Guy Consulting, LLC
> Unix and Linux Automation, Shell, PERL and CGI scripting
> http://www.unix-guy.com

This link explains it all:
http://www.faqs.org/docs/abs/HTML/p...bstitution.html
Sashi






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 05:12 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