I am running Ansible on multiple machines and redirecting the output to a file, say log-$(date), which is mailed to me every day. The output file has multiple text colors, how to turn them off? Sendmail sends output which contains [0;32m, [0;33m, [0;36m, etc.

Is there an option in sendmail? Or in Ansible settings? (I don't want to turn it off in Ansible.)

  • I am using ansible. Tail the log and use sendmail to send it. – Sand1512 Dec 16 '15 at 18:03

Ask the program that produces those colors to stop, or remove those colors yourself:

sed "s,\x1B\[[0-9;]*[a-zA-Z],,g"

^I have this in an executable named uncolor so that I can do:

aProgramThatWontStopColoring | uncolor
  • 1
    It worked. Great. tail -32 log-2015-12-16_22-53 | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | sendmail "san1512@mailtest.com" – Sand1512 Dec 16 '15 at 18:06

Your Answer

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

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