I'm trying to redirect the output of a command into mailx.
if grep -B 1 line $curccrtpick; then
grep -B 1 line $curccrtpick | head -2 > tempmsg
mail -s "String found in $curccrtpick" -r [email protected] [email protected] < tempmsg
#rm tempmsg
else
echo nothing
fi
But it appears as a binary file in the form of an attachment (ATT00001.bin)
When I run
tr -d '[\015\200-\377]' < tempmsg > tempmsg1
and redirect that file into mailx I receive the email in a one liner:
thefirstlinethesecondline
when there should be two
thefirstline
thesecondline
This is the logic that worked for me. Utilizing sendmail seems more appropriate than mailx.