FG
💻 Software

Removing ANSI color codes from text stream

Fresh5 days ago
Mar 15, 2026156159 views
Confidence Score1%
1%

Problem

Examining the output from in a text editor (e.g., ) shows the following: How would one remove the ANSI color codes from the output file? I suppose the best way would be to pipe the output through a stream editor of sorts. The following does not work

Error Output

perl -e 'use Term::ANSIColor; print color "white"; print "ABC\n"; print color "reset";'

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Removing ANSI color codes from text stream

Low Risk

The characters and are part of the ANSI escape sequences (CSI codes). See also these specifications. Using GNU (or ) is the escape special character (GNU does not support alternatives and ) is the second character of the escape sequence is the color value(s) regex is the last character of the escape sequence Using the macOS default Mike suggests: The macOS default does not support special characters like as pointed out by slm and steamer25 in the comments. To install . Example with OP's command…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment