INPUT:
[user@notebook test]$ cat a.txt
music
musicsheet
sheetmusic
[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
music
musicsheet
sheetmusic
[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
^[[24m
what 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]$
ls > a.txt
? It would be much simpler to just regenerate the file. And do you really need the$
? Or do you just want a newline character at the end of each line? Please [edit] your question and clarify. – terdon Jan 23 '17 at 11:53