This question already has an answer here:

I searched but did not find this answer. I am running an old RedHat 5.3 system on one server (working on upgrade to 7 in progress) but I want to send 2 text files using the mail command. I do this all the time with a single file like this:

mail username -s 'MySubject' < /home/directory/file1.txt

I tried this:

mail username -s 'MySubject' < /home/directory/file1.txt < /home/directory/file2.txt

But that send the output of the first part including the results of the mail command along with both text files.

Is there a better way to do this?

marked as duplicate by Jeff Schaller, Thomas, msp9011, Archemar, Kusalananda linux Jan 21 at 13:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You'll need to concatenate the two files into a single unit before piping them to the mail command. Like this, for example:

cat /home/directory/file1.txt /home/directory/file2.txt | mail username -s 'MySubject'

Not the answer you're looking for? Browse other questions tagged or ask your own question.