linux - Maintain line breaks in output from subshell -


when execute subshell obtain output of command, line breaks lost.

for example:

filenames=$(grep 'foobar' /some/dir) echo $filenames 

assuming there more 1 file in /some/dir contains string "foobar", filenames printed in 1 long space-separated line instead of 1 filename per line.

i can't use tr convert spaces line breaks since filenames have spaces in them anyway.

is there way maintain line breaks?

quote variable print newlines:

filenames=$(grep 'foobar' /some/dir) echo "$filenames" 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

php - Boolean search on database with 5 million rows, very slow -

css - Text drops down with smaller window -