-1

I am trying to replace some sequence of character with a blank. But I am not able to replace it.

File name is Test:

id       ^[[0mevent^[[0m            ^[[0msuite^[[0m                                     ^[[0mok^[[0m     ^[[0mnok^[[0m    ^[[0mskip^[[0m  test  up        owner     du     duplex  type   stp             inst_type  prep  created              finished

I am trying to replace ^[[0m with a blank character. To do so I am using the following command to achieve the aforementioned task.

sed 's/\^\[\[0m//g' Test

However, the above command is having not impact.

The problem is due to coloured font.

enter image description here

Thanks!!

John Rambo
  • 906
  • 1
  • 17
  • 37

2 Answers2

1

You are replacing it with z just remove the z also instead of 0 seems that you have typed big O. Change it to 0 then it will work very well:

~$ echo "id       ^[[0mevent^[[0m            ^[[0msuite^[[0m"|sed 's/\^\[\[0m//g'
id       event            suite
Mazdak
  • 105,000
  • 18
  • 159
  • 188
0

I have used the following command to replace the colored text:

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

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

John Rambo
  • 906
  • 1
  • 17
  • 37