Quote:
Originally Posted by thamann
What does the $ mean?
I put it here:
echo "$EAGLE_users"
but I also see in the example:
$ echo "$EAGLE_users\n"
inquiring minds want to know?? can you recommend a good book?
T
|
Well, you have already got the answer to your original question. So, I talk about this one which is already answered. But let me explain you smoe more in details:
In Shell Script (on Unix / Linux) when you set a variable's value you do not use a $ before the variable's name:
and you do not leave any space before and after the
= sign.
When you want to use a variable's value then you simply prefix it with a $ sign:
You can think of the $ sign as:
Substitute whatever is contained by the variable sticking next to me.
If you put single quotes:
then the output would be:
$NUM
and not 1.
Double quotes will do the substitution operation first before giving the output.
Try this:
Code:
files=`ls -l`
echo -e "This is going to be a mess here...\n"
echo $files
Now try this:
Code:
files=`ls -l`
echo -e "This is going to be nice...\n"
echo "$files"
Note the backticks, they are not single quotes:
`backticks
`
Also note that
-e with
echo will interpret the escape character which is
\n in the above example.
Sycamorex has suggest you an excellent guide: Advanced Bash Script.
You can also check Beginner's Bash Script guide on the same web site:
http://tldp.org
and there are PDF versions also.