3

I am new to the linux and shell scripting. I have a script, which has some read commands in it. So, something like

#script1.sh
echo "something here" 
....
read var1
read var2
...

Now, i want to write another script that calls this script and can pass the values to this script. So, i'm hoping for something like,

./script2.sh hello world

And, that would run script2 and store "hello" in var1 and "world" in var2. What should this script2 contain and how can i pass these arguments to script1?

I have searched for this a lot but i didn't find anyone explaining this.

2

1 Answer 1

4

Calling script2.sh from script1.sh

#script1.sh
./script2.sh hello world

In script2.sh

var1 =$1 
var2 =$2
echo $var1
echo $var2

Ouput will be hello world

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .