Interview Prep/Shell Scripting/Text processing: grep, sed, awk, cut, sort, uniq

How do you strip ANSI colour codes or carriage returns from tool output?

BeginnerConceptText processing: grep, sed, awk, cut, sort, uniq
Answer
sed -E 's/\x1B\[[0-9;]*[A-Za-z]//g' ci.log > clean.log
tr -d '\r' < output.txt
kubectl logs pod --no-color 2>/dev/null || kubectl logs pod | sed -E 's/\x1B\[[0-9;]*m//g'

Prefer turning colours off at the source (--no-color, NO_COLOR=1, TERM=dumb) so log parsers and alert rules see plain text.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Text processing: grep, sed, awk, cut, sort, uniq