Sample Header Ad - 728x90

Cat file and heredoc to pipe

0 votes
2 answers
133 views
I do some automatic checks and want to send a mail if a file has changed. I want the mail body to contain the new version of the file, some static text and the old version of the file, so what I do is cat mettab.txt metalerttext.txt mettab.old.txt | /usr/bin/mail -s Metalerts (...) where mettab.txt is the new version, metalerttext.txt is a static file and mettab.old.txt is the old version. but, rather than using metalerttext.txt, I feel it would be better to use a heredoc. But is it possible to do that in a single line as above, or is the only possibility to make a temporary file and do something like: cp mettab.txt mailtemp.txt cat > mailtemp.txt cat mettab.old.txt >> mailtemp.txt before mailing mailtemp.txt and deleting the file. Or have I overlooked someting? (metalerttext.txt is just one line)
Asked by MortenSickel (1433 rep)
May 31, 2024, 12:42 PM
Last activity: May 31, 2024, 07:04 PM