|
Home > Archive > Unix questions > January 2006 > unix variable meaning (might be echo)
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
unix variable meaning (might be echo)
|
|
| siddharthkrish@gmail.com 2006-01-13, 10:40 pm |
| 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
| |
| Ed Morton 2006-01-13, 10:40 pm |
| 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.
| |
| Sashi 2006-01-13, 10:40 pm |
|
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
| |
| Kevin Collins 2006-01-13, 10:40 pm |
| 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
| |
| Sashi 2006-01-13, 10:40 pm |
|
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
|
|
|
|
|