LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How can terminal control characters be removed from the file created in linux (https://www.linuxquestions.org/questions/linux-newbie-8/how-can-terminal-control-characters-be-removed-from-the-file-created-in-linux-911530/)

pandunr 11-02-2011 01:33 PM

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

catkin 11-03-2011 12:43 AM

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?

pandunr 11-23-2011 10:31 AM

I have tried with sed but not all terminal characters are removed. Like back space, tab etc

catkin 11-27-2011 11:34 PM

Can you post a sample file (as an attachment) and the sed command you tried?

michaelbohler 02-09-2012 03:43 PM

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]

Cedrik 02-09-2012 04:13 PM

Would this work:
Code:

echo -e $line | tr -d '[:cntrl:]'

michaelbohler 02-09-2012 04:32 PM

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.