Maintain line breaks in output from subshell August 24, 2023 by Tarik Quote the variable to print the newlines: filenames=$(grep 'foobar' /some/dir) echo "$filenames"