-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2281
Joachim Ansorg edited this page Nov 12, 2021
·
3 revisions
$greeting="Hello World"
${greeting}="Hello World"
greeting="Hello World"
Alternatively, if the goal was to assign to a variable whose name is in another variable (indirection), use declare
:
name=foo
declare "$name=hello world"
echo "$foo"
Or if you actually wanted to compare the value, use a test expression:
if [ "$greeting" = "hello world" ]
then
echo "Programmer, I presume?"
fi
Unlike Perl or PHP, $
is not used on the left-hand side of =
when assigning to a variable.
None