Issue
I am new to writing Shell Scripts and am having some difficulties.
What I Want To Achieve
I have an array of strings in scriptOne.sh
that I want to pass to scriptTwo.sh
What I Have Done So Far
I can execute the second script from inside the first using ./scriptTwo.sh
and I have passed string variables from one to the other using ./scriptTwo.sh $variableOne
.
The issues are when I try to pass an array variable it doesn't get passed. I have managed to get it to pass the first entry of the array using ./scriptTwo.sh "${array[@]}"
however this is only one of the entries and I need all of them.
Thanks in advance for your help
Solution
Your way of passing the array is correct
./scriptTwo.sh "${array[@]}"
The problem is probably in the way how you receive it. In scriptTwo.sh
, use
array=("$@")
Answered By - choroba Answer Checked By - Senaida (WPSolving Volunteer)