0

I have many BASH scripts called in sequence, e.g., script1.sh contains:

#!/bin/bash

bash script2.sh
bash script3.sh
bash script4.sh

script2.sh contains:

#!/bin/bash

file_a="1.txt"

cp $file_a /tmp/$file_a.tmp

script3.sh contains:

#!/bin/bash

wc -l /tmp/$file_a.tmp

script4.sh contains:

#!/bin/bash

cat /tmp/2.txt $file_a.tmp > file3.txt

Each file requires access to a small collection of variables. How can I pass the variables from one script onto the next?

0

1 Answer 1

0

You have many options.

The first method would be making the variable as the environment variable and pass to the script before the second script get executed.

The second method would be making the second script to run in the same shell.

The methods are described well here with the examples.

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.