In the bash command line, I set a variable myPath=/home/user/dir . I created a script in which I put echo $myPath but it doesnt seem to work. It echoes nothing. What can I do to access the myPath variable in the script. If I write echo $myPath in the command, it works, but not in the script.
how did you assign the variable? it should have been:
$ export myPath="/home/user/dir"
then inside a shell program like:
#!/usr/bin/env bash echo $myPath
you'll get the desired results.