Store multiline output in separate variable

A script outputs 3 line output:

$ Filename /a/Resource/.Filename.man.markdown
.Filename.man.markdown
.Filename
man.markdown

What I want to do

I want to store the 3 line output in separate variable, how can I do it?


I tried the following – Why it fails and how to do it correctly?

1st failed attempt

Filename /a/Resource/.Filename.man.markdown | IFS=$'n' read -r File1 Filename1 Extension1
echo "$File1 $Filename1 $Extension1"

2nd Failed attempt

$ IFS=$'n' read -r File1 Filename1 Extension1 < <(Filename /a/Resource/.Filename.man.markdown)
$ echo "$File1 $Filename1 $Extension1"
.Filename.man.markdown  
Asked By: Porcupine

||

With bash:

read -r -d 'n' a b c < <(Filename /a/Resource/.Filename.man.markdown)
echo "$a $b $c"

Output:

.Filename.man.markdown .Filename man.markdown

See: help read

Answered By: Cyrus
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.