I have a bash script that runs and outputs to a text file however the colour codes it uses are also included what i'd like to know is how to remove them from the file, ie
^[[38;1;32mHello^[[39m
^[[38;1;31mUser^[[39m
so I just want to be left with Hello and User
My solution:
The colon is there to support escapes for some old terminal types.
Does this solve the issue?
cheers!!
this command removes the special characters and color codes from the file
these are some of ANSI codes:
ESC[#;#H or ESC[#;#f
moves cursor to line #, column #ESC[2J
clear screen and home cursorESC[K
clear to end of line,note in case of clear code there is neither number nor semicolon
;
agree with below comment: if the numbers are more than 2 digit kindly use this: