How can terminal control characters be removed from the file created in linux
I'm createing a file in Linux using command
cat <<EOM! | sudo -u gmepdmpp tee -ai test.log >/dev/null But the log file is storing all the control character like ^M, ^H, ^K, ^B and other terminal characters. I tried with dos2unix ( removes only control ^M) and also tried to remove using sed. But I have not able to remove all control and terminal characters How can these terminal characters be removed from file. Quick response is highly appreciated |
What did you try with sed? Which control characters did it not remove? Are the characters you want to remove only control characters or are there sequences of characters, preceded by a control character, that you want to remove?
|
I have tried with sed but not all terminal characters are removed. Like back space, tab etc
|
Can you post a sample file (as an attachment) and the sed command you tried?
|
If I may jump in, here is an example I am working on. I'd like to use sed to remove all the control characters, ^[[60G[^[[0;32m and ^[[0;39m], from this line:
Stopping httpd: ^[[60G[^[[0;32m OK ^[[0;39m] |
Would this work:
Code:
echo -e $line | tr -d '[:cntrl:]' |
Yes, that is working. I'll need to tailor it a little as some of the lines in the file I'm working with are a little different. Much simpler than sed. Thanks!
|
All times are GMT -5. The time now is 05:07 AM. |