INPUT: [user@notebook test]$ cat a.txtmusicmusicsheetsheetmusic[user@notebook test]$ cat a.txt | cat -vte -$^[[1mmusic^[[22m$^[[1mmusicsheet^[[22m$^[[1msheetmusic^[[22m$^[[4m^[[24m$[user@notebook test]$ NEEDED OUTPUT (after removing these interesting characters): [user@notebook test]$ cat a.txt musicmusicsheetsheetmusic[user@notebook test]$ cat a.txt | cat -vte -music$musicsheet$sheetmusic$[user@notebook test]$ Question: How can I remove the interesting/unknown characters: ^[[1m^[[22m^[[4m^[[24mwhat are these characters? could there be more similar? Trying to use tr to remove non-printable characters just makes these interesting chars visible and removes newline, what is both bad: [user@notebook test]$ cat a.txt | tr -cd '[:print:]'[1mmusic[22m[1mmusicsheet[22m[1msheetmusic[22m[4m[24m[user@notebook test]$ 
How to remove the ^[[1m ^[[22m ^[[4m ^[[24m characters while keeping the newline?
special characters
@Toby Speight's solution is fine. Some extra information:Normally those are the ansi special character used to produce color, special effects, position the cursor, etc in the terminal.for example grep --color=always '[a-z]*music[a-z]*' files > output will produce characters like that.sed -r s/\x1B\[[0-9;]*[a-zA-Z]//gSugestion: check if you have a GREP_COLOR deprecated variable set to --color=always or similar...