Skip to main content
1 of 2
Ijaz Ahmad
  • 7.4k
  • 7
  • 35
  • 46

You must run the assignment and echo test srcipt in the same shell.

root@ijaz-HP-EliteBook-8560p:~# foo=bar
root@ijaz-HP-EliteBook-8560p:~# cat test.sh 
   #!/bin/bash
   echo "$foo"
root@ijaz-HP-EliteBook-8560p:~# . test.sh 
bar

this is just one way of doing it.

Ijaz Ahmad
  • 7.4k
  • 7
  • 35
  • 46