First time posting here.
I have the following file and contents:
linux$ cat file.txt
line 1
line 2
line 3
line 4
I have the following code:
Output=$(cat file.txt)
echo "$Output" | mail -s "[Test]" -a test.txt host@domain.com
I send the file itself as attachment for debugging purpose. The problem I encounter is that the email body containing the output of 'cat file.txt' looks like this:
line 1
line 2 line
3 line 4
The attached file contains a correctly formatted output of 'cat file.txt', no characters, newlines, spaces are added or removed.
What might be causing this? Appreciate your help!