Answer the question
In order to leave comments, you need to log in
What is the difference between $var and ${var}?
Gentlemen, explain to me, unlucky, what is the difference between $var and ${var}?
There is a script that bites a variable from a file and writes it to the database:
filename=/home/pi/adc/work/integral/$(date "+%Y/%m/%Y%m%d.txt")
var=$(tail -1 $filename | head -1 | cut -c26-30 | tr -d ' ')
rrdtool update /home/pi/adc/PIstat.rrd N:$var
Answer the question
In order to leave comments, you need to log in
{} explicitly limits the indication of the place where the name of the variable ended. \
In fact, this is the same thing (in this case).
But with this construction:
echo blah${var1}blah${var2} blah${var3}${var4}var1 you will have problems for yourself.
And there will be problems if you have variables
$var1var2
$var1
And you want to do:
echo ${var1}var2
Well, in general, writing {} is considered good form, even if this is not required in your design - it increases the readability of scripts.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question