title: Removing colors from output
body: <p>I have some script that produces output with colors and I need to remove the ANSI codes.</p>
  
  <pre><code>#!/bin/bash
  
  exec &gt; &gt;(tee log)   # redirect the output to a file but keep it on stdout
  exec 2&gt;&amp;1
  
  ./somescript
  </code></pre>
  
  <p>The output is (in log file):</p>
  
  <pre><code>java (pid  12321) is running...@[60G[@[0;32m  OK  @[0;39m]
  </code></pre>
  
  <p>I didn't know how to put the ESC character here, so I put <code>@</code> in its place.</p>
  
  <p>I changed the script into:</p>
  
  <pre><code>#!/bin/bash
  
  exec &gt; &gt;(tee log)   # redirect the output to a file but keep it on stdout
  exec 2&gt;&amp;1
  
  ./somescript | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
  </code></pre>
  
  <p>But now it gives me (in log file):</p>
  
  <pre><code>java (pid  12321) is running...@[60G[  OK  ]
  </code></pre>
  
  <p>How can I also remove this '<code>@[60G</code>?</p>
  
  <p>Maybe there is a way to completely disable coloring for the entire script?</p>