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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.