I am new to Linux, pardon any wrong terminology used here.
I am using Ubuntu 18.04. I am reading text in a shell script using read
command. I have a variable in bash window that I want to substitute in that read command. My shell script looks like this:
echo "Enter Text"
read text
echo "Text is $text"
Then I execute it like this in terminal
user@machine:~$ var="hello world"
user@machine:~$ ./script.sh
Enter text
$var
Text is $var
user@machine:~$
Notice the line in output - Text is $var
.. how can I make it read the value of variable var
so it stores hello world
in variable named text
?
NOTE: I know there is an option to pass parameters to scripts, but I find this more intuitive for the user executing script hence wanted to know how to do it this way!
export SOME_LONG_VARIABLE_NAME="variable content"
. Then typeecho $SOME_L
and [tab][enter]