1

I've a code which 'grep' certain strings from two files which I've defined as variables and if those strings are found then it'll send me the last 10 lines of the files using tail. I want the strings in my output mail in green color format. Is this anyway possible? Below is my code:

grep "xyz" $File2
if [ $? -eq 0 ]
then
echo "Process finished, Below are the logs : \n `tail $File2` |mailx -s "Logs" user1@ace.com
else
exit 1
fi
  • You'd probably have to generate full HTML output for that. ANSI terminal escape sequences (which do the coloring) aren't understood by any mail client I'm aware of. – Ulrich Schwarz Aug 26 '17 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.