1

I execute a bash script with following command:

./testscript &

It includes:

#!/bin/bash
export testvar=OK
...

How can I access testvar from another bash script?

M1NT
  • 386
  • 1
  • 4
  • 13

1 Answers1

2

You need to source in testscript into another script for that using:

source ./testscript

OR else:

. ./testscript

That way you avoid creating a sub shell while executing ./testscript hence variable created remain in scope.

anubhava
  • 761,203
  • 64
  • 569
  • 643