if [ "$(uname -s)" == "SunOS" ]; then
END=$(printf '\033[0m')
DECOLORIZE='eval sed "s,${END}\[[0-9;]*[a-zA-Z],,g"'
else
DECOLORIZE='eval sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,3})*?)?[m|K]//g"'
fi
=> howto use:
<commands that type colored output> | ${DECOLORIZE}
tested on:
- AIX 5.x / 6.1 / 7.1
- Linux Mandrake / Mandriva / SLES / Fedora
- SunOS