I need to assign multiline output of command to a variable. I read these two threads:
assigning the output of a command to a variable in a shell script
Capturing multiple line output into a Bash variable
and it works for echo example (multiline commands):
#!/bin/bash
output="$( bash <<EOF
echo first
echo second
echo third
EOF
)"
echo "$output"
but it seems to not working for one command with multiline output. When I run
output="$( bash <<EOF
echo abc
uncrustify -c ~/.uncrustify.cfg --check filename
echo def
EOF
)"
I will receive the second line of default uncrustify -c ~/.uncrustify.cfg --check filename
output:
FAIL: filename (File size changed from 404 to 417)
Default output for uncrustify -c ~/.uncrustify.cfg --check filename
is:
Parsing: filename as language OC
FAIL: filename (File size changed from 404 to 417)
I want to assign both of these lines to output variable and hide all outputs to console.