In /etc/environment
I have declared a variable "myvar" as:
myvar='abc$#abc'
.
I need to use the varibale in a script. When I print the variable through the script, The string gets chopped off after '$' character.
echo $myvar
Result:
abc$
.
Fix(But why is this working?):
When I include source /etc/environment
in the script, the variable is retrieved correctly.
#!/bin/bash
echo $myvar
source /etc/environment
echo $myvar
Result:
abc$
abc$#abc
Why is this working? And how can I make it work without using source
?