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?

0

1 Answer 1

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.