sed -r "s/x1B[(([0-9]{1,2})?(;)?([0-9]{1,2})?)?[m,K,H,f,J]//g" file_name
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 cursor
ESC[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:
sed -r "s/x1B[(([0-9]+)(;[0-9]+)*)?[m,K,H,f,J]//g" filename
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…