LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-02-2011, 02:33 PM   #1
pandunr
LQ Newbie
 
Registered: May 2011
Posts: 12

Rep: Reputation: Disabled
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
 
Old 11-03-2011, 01:43 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
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?
 
Old 11-23-2011, 11:31 AM   #3
pandunr
LQ Newbie
 
Registered: May 2011
Posts: 12

Original Poster
Rep: Reputation: Disabled
I have tried with sed but not all terminal characters are removed. Like back space, tab etc
 
Old 11-28-2011, 12:34 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Can you post a sample file (as an attachment) and the sed command you tried?
 
Old 02-09-2012, 04:43 PM   #5
michaelbohler
LQ Newbie
 
Registered: Feb 2012
Posts: 2

Rep: Reputation: Disabled
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]
 
Old 02-09-2012, 05:13 PM   #6
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
Would this work:
Code:
echo -e $line | tr -d '[:cntrl:]'
 
1 members found this post helpful.
Old 02-09-2012, 05:32 PM   #7
michaelbohler
LQ Newbie
 
Registered: Feb 2012
Posts: 2

Rep: Reputation: Disabled
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Terminal shows unicode squares for control characters ghostknife Linux - Software 5 12-30-2009 06:46 AM
Handling Control Characters in Linux. bala.linux Linux - General 3 03-27-2008 02:28 PM
Viewing control characters in a text file dmorse Linux - General 2 01-07-2007 12:10 AM
Clearing control characters from a text file LinuxLala Linux - General 1 04-07-2006 07:45 AM
Can i limit new file names created to 8 characters with samba ? amitsharma_26 Linux - Networking 1 12-16-2005 06:42 AM


All times are GMT -5. The time now is 06:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration