Computing.Net > Forums > Unix > Replace ^M, ^H, ^G Characters Unix

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Replace ^M, ^H, ^G Characters Unix

Reply to Message Icon

Name: Shanthi
Date: July 18, 2006 at 07:08:56 Pacific
OS: Unix
CPU/Ram: 1GB
Product: Sun
Comment:

Hi I am using the "script" command in unix to log all the activities performed by users. However, the file generated has a lot of ^M, ^H, ^G characters in it.
I would like to know I can suppress these? Or eliminate these using some command.

R.Shanthi



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: July 21, 2006 at 20:42:41 Pacific
Reply:

One way is to use the tr command to delete the control characters using octal values. Since the octal values of ^M, ^H, ^G are 015, 010, 007 respectively, this command deletes the 3 control characters:

tr -d '\015\010\007' < data.file > new.data.file

If you need the value of other control characters, but do not have an ASCII chart, use this method to deterine the value: from within vi and in an edit mode, press control-v and then press the control character. Save the file and perform an od -b command on the file. This displays the octal value.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Replace ^M, ^H, ^G Characters Unix

I'm a beginner www.computing.net/answers/unix/im-a-beginner/4069.html

unix text file parser www.computing.net/answers/unix/unix-text-file-parser/5430.html

spefic SED replace command www.computing.net/answers/unix/spefic-sed-replace-command/6058.html