Linux - sed to clean up "color codes" or escape sequence

If you see

drwxr-xr-x   23 abc xyz          4096 May 24  2011  [00;34m. [00m/
drwxrwsr-x    4 abc xyz          4096 May  3 01:14  [00;34m.. [00m/

in your directories, you could use the following to remove the color code.


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


Reference:

1. http://www.commandlinefu.com/commands/view/3584/remove-color-codes-special-characters-with-sed

Comments

Popular Posts