Skip to main content

You mustcan run the assignment and echo test srciptscript in the same shell.

root@ijaz-HP-EliteBook-8560p:~# export 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.

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.

You can run the assignment and echo test script in the same shell.

root@ijaz-HP-EliteBook-8560p:~# export 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.

Source Link
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.