Quote:
in my script if I put echo $STORNUM I get nothing.
I tried
echo `$STORNUM`
echo !$STORNUM
echo `STORNUM`
How do I echo the .profile value to the screen?
|
There are several things going on here:
(0) as the Squashman notes, there should be no spaces on either side of the equals sign in an assignment statement.
(1) different quotes mean different things to the shell. For example, single quotes mean (roughly) "take everything I typed literally" -- i.e., if you type asterisk (*), then the shell does NOT expand it; rm * is NOT the same as 'rm *'. The first attempts to remove all files in the current directory; the second attempts to remove a file named * in the current directory. Double quotes allow filename and globbing (wildcard) expansion, as well as environmental variable substitution. For example, rm "this is a test" attempts to remove a file named "this is a test" (without the quotes) in the current directory. The command: rm this is a test attempts to remove four files named this, is, a and test in the current directory. In this case, there would be no difference between the single and double-quote meaning, because the command contains no globbing, filename expansion or variable substitution. However, the command rm 'this is*' is not the same command as rm "this is*"; the first attempts to remove a file named "this is*" in the current directory, while the second attempts to remove all files that begin with the characters "this is" in the current directory.
(2) back-tics (accent grave -- i.e., `) execute what is contained between the back-tics as a command.
(3) the exclamation point is usually used as a shell escape from within a program (such as vi, for example) and often allows you to execute a command and capture the output. Note that you may need a space between the exclamation point and the command to be executed. However, if you code echo !$STORNUM, the shell will first perform variable substitution and replace $STORNUM with its value (4, in this case?) and then display !4 to the screen.
Here's how I suspect the shell interpreted your attempts:
Code:
echo `$STORNUM` -> displayed $STORNUM (literally) on the screen
echo !$STORNUM -> displayed ! followed by the value of STORNUM on the
screen
echo `STORNUM` -> shell attempts to execute a command named STORNUM
and echo the results. Since there is likely no command
named STORNUM, the shell produces an error. Quoting can be very confusing (and that's only the beginning!

). Hope this helps.