If inner.sh is
#...
echo first
echo second
echo third
And outer.sh is
var=`./inner.sh`
# only wants to use "first"...
How can var be split by whitespace?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try this:
Output:
Explanation:
var=(first second third), for example.$(./inner.sh)runs theinner.shscript, which prints outfirst,second, andthirdon separate lines. Since we don’t didn’t put double quotes around$(...), they get lumped onto the same line, but separated by spaces, so you end up with what it looks like in the previous bullet point.