udaya udaya - 1 year ago 102
Linux Question

Regex match for color response in linux

I have a colored response from one of my server. I have a regular expression which is NOT working on that server. If I go to any other server, the response comes in black and it matches fine. Also I took the response and tried out other regular expression matching web sites and t worked smooth.

Any suggestion how to match the specific regular expression OR how we can change the color setting for the text . The specific server is "CentOS release 5.5 (Final)"


Answer Source

Colors are contained in the output in the form of ANSI escape sequences. You can remove the color codes by replacing all occurrences of


Or, since your output seems to be from ls, simply use its --color=never option.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download