Remove color codes (special characters) with sed

sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"

24
By: Cowboy
2009-09-23 12:06:33
sed

10 Alternatives + Submit Alt

What Others Think

See also http://www.pixelbeat.org/scripts/ansi2html.sh for other possible codes to strip
pixelbeat · 626 weeks ago
Just what I needed for cleaning the capture of the 'script' command. Thanks!
funollet · 620 weeks and 1 day ago
Does this work when you have 2 colors on a line?
matthewbauer · 619 weeks and 5 days ago
badass. nice seddage :) i wonder if there is a simpler way to do it with simple redirection of stdout.. hmm not sure yet. anyway awesome, i'm using this for now xD
kevinquinnyo · 502 weeks and 4 days ago
FWIW, the `-r` does not work with `sed` on Mac OS-X.
jaytaylor · 429 weeks and 6 days ago
Is there any way to undo the effect of sed command?
Wajiha · 387 weeks and 3 days ago
https://www.shampooadvice.com/ https://www.shampooadvice.com/best-pregnancy-safe-shampoos/
jessicacoles · 50 weeks ago
Recently i have found this website and it is one of the best learning platforms for students nowadays. They can Don Julio Real Extra Anejo Tequila easily learn the commands from here. Various opinions from experts are listed here and you can also ask any kind of doubts here. They will definitely provide a clear solution for all your doubts.
Alyssalauren · 31 weeks and 2 days ago
Here they have discussed the steps to remove color codes from text with sed so those who really want to know about it Punctual Duo The Step or wish to know the code can go through this post in which they have very well explained about the ways to remove special characters using the sed
Kaitlyn · 22 weeks and 5 days ago
With the innovation that we have today and how exorbitant production and maintenance are, organizations have been rethought their seaward development IT cycles to remote staff and seaward teams utilizing research and development focuses or assemble operate transfer models. Organizations choosing to expand their reach and collaborate with various global IT enterprises, as well as utilize their administrations, have encountered the benefits of seaward developer teams. Development costs being a fraction of the usual expense, more proficient teams, and quality yield are only a couple factors that drive interaction and development outsourcing to seaward development teams. When can you say that a seaward development team is a decent set-up for your project, and that you should hire seaward developers who will be beneficial for your organization? There are various reasons as to why a seaward software developers is the most ideal option for you and your company. A seaward development team can bring a plethora of benefits and seaward software developers can be an immense asset to your team. However, aside from the benefits to be had when working with dedicated seaward teams, another essential component is what are our priorities or intentions while considering seaward development teams chipping away at seaward software development projects. The priorities that you have dealing with a project can be your critical determinant in choosing whether or not to hire seaward developers for your project. Working with seaward development teams offer you the opportunity to work with a gathering of best seaward developers that will share project tasks and work towards achieving the goals and targets set for your project. With these priorities as a primary concern, employing best seaward dev teams is the most ideal option for you and your company. On the off chance that you choose to go the course of seaward software development and building a nearshoring team to deal with your project, you get a plethora of benefits that would greatly appeal to your business. Here are probably the greatest advantages that recruiting a seaward development team to deal with your seaward software development brings to the table.
JeremyYang · 19 weeks and 6 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: