The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
escaping special characters in file name... lau0001 Shell Programming and Scripting 1 01-19-2008 08:54 PM
Removing special characters in file srivsn Shell Programming and Scripting 6 01-03-2008 06:10 AM
How to delete a file with special characters yveslagace UNIX for Dummies Questions & Answers 5 08-22-2007 11:42 AM
how to see special characters in a file using vi jingi1234 UNIX for Dummies Questions & Answers 6 10-19-2005 11:57 AM
search special characters in a file cramya80 UNIX for Dummies Questions & Answers 2 05-13-2005 12:08 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-13-2006
solai solai is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 1
Replace Special characters in a file

Hi,

I have a data like this in a file,

402003279034002000100147626030003300010000000000002000029000000 ær^M^\MÍW^H

I need to replace those special char to some other char like # or $

Is there any ways to do it…

I tried commands tr,sed and many but it was not able to replace because of the special characters and ^M type of characters

I need it to be replaced and also the number of bytes of the file should not be altered.

There are lots of similar data in this file… I have to replace all the occurrence of the special characters. I know the start-byte and end–byte of the same
  #2 (permalink)  
Old 07-13-2006
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
You can use POSIX character classes with tr
Code:
tr -s '[:cntrl:]' '#' < filename   > newfilename
This converts all of the control characters (those ^M, etc) characters to a # in filename then writes the output to newfilename.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0