2

I am trying a run a script inside another script as below:

$a="$(sh test_part.sh /AB/pass_file.txt)"
echo $a

Now sh test_part.sh /AB/pass_file.txt returns an output like below:

ABD
SDFDR
TDFDG
DGFKFH

I want to store that in the variable $a as it is. With my current script I am getting below error:

test_part.sh: line 2: $'=ABD\nSDFDR\nTDFDG\nDGFKFH': command not found
7

You should not have $ prefix while declaring a variable in the shell.

Try as

a="$(sh test_part.sh /AB/pass_file.txt)"
echo "$a"

or

a=($(sh test_part.sh /AB/pass_file.txt))
echo "${a[@]}"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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