Operating System - HP-UX
1748157 Members
4057 Online
108758 Solutions
New Discussion юеВ

Re: Managing variables -very important

 
Dennis Handly
Acclaimed Contributor

Re: Managing variables -very important

>MK: If your variable contains semi-colons and the variable expansion is not quoted, the first semi-colon will terminate the echo command

Not hardly, a real shell doesn't look for a ";" after variable expansion:
$ x="abc;def"
$ echo $x
abc;def

The reason you quote things is because you want to preserve the whitespace.
Dennis Handly
Acclaimed Contributor

Re: Managing variables -very important

>echo "${TAP OUT}" > file02.txt

You can't do that. You can't have spaces in a variable name. You would get:
ksh: "${TAP OUT}": bad substitution
Marco_ALT
Esteemed Contributor

Re: Managing variables -very important

when i substitute with the following

x="TAP OUT"
echo $x > file02.txt;

i received the e-mail contaning "TAP OUT" as the body!!

i need to subistitue with the variable value
ie $TAP OUT not the name char "tap out"

shall i do it like
x="${TAP OUT}"
echo $x.........
?
plz advise
Dennis Handly
Acclaimed Contributor

Re: Managing variables -very important

>I need to substitute with the variable value
ie $TAP OUT not the name char "tap out"

You can't have a variable with embedded spaces.

If you want to do variable "indirection":
$ x=9
$ y=10
$ z=x
$ eval echo \$$z
9