How to replace special characters?

Tags
shell scripts

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 10-30-2012
How to replace special characters?

Hi Unix Guru,

I have an requirement for replace some specail characters in a file, my file came from mainframe.
please see below example:
when open it with vi
Code:
17896660|89059215|04/24/1998 00:00:00.000000| abc 123-453-1312^M<85>^M<85>|124557

if I run cat -v I got following:
Code:
17896660|89059215|04/24/1998 00:00:00.000000| abc 123-453-1312^MM-^E^MM-^E|124557

there are more than 10000 records

my question is how can I remove these special characters.

Thanks in advance

Smilie
# 2  
Old 10-30-2012
Are they at a fixed location in the line?
Eks:after number, but before |
# 3  
Old 10-30-2012
Quote:
Originally Posted by Jotne
Are they at a fixed location in the line?
Eks:after number, but before |
No, they are in fixed field but the field's content changed
# 4  
Old 10-30-2012
Try using the below command on your file and redirect the output to a new file and check if the special characters are removed:-

Code:
sed 's/'"$(printf '\015')"'//g' input_file > output_file

# 5  
Old 10-30-2012
Quote:
Originally Posted by bipinajith
Try using the below command on your file and redirect the output to a new file and check if the special characters are removed:-

Code:
sed 's/'"$(printf '\015')"'//g' input_file > output_file


thanks for you reply, I tried it. it removed one ^M. the file looks as following:
Code:
 
17896660|89059215|04/24/1998 00:00:00.000000| abc 100-453-1312M-^EM-^E|124557

using vi
Code:
17896660|89059215|04/24/1998 00:00:00.000000| abc 100-453-1312<85><85>|124557

anyidea?

Thanks in advance
# 6  
Old 10-30-2012
So using vi you are not seeing ^M characters anymore, is that correct? Also do you want to remove < & > symbols ?
# 7  
Old 10-30-2012
Quote:
Originally Posted by bipinajith
So using vi you are not seeing ^M characters anymore, is that correct? Also do you want to remove < & > symbols ?
Yes, I need to remove <85><85> because this is a invisable character.
Login to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Similar Threads More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to replace special characters? Ravi.K UNIX for Advanced & Expert Users 4 04-22-2017 04:04 AM
How to replace value of password tag in xml with blanks when special characters are there? saroopkris85 How to Post in the The UNIX and Linux Forums 7 10-27-2015 04:35 PM
Search special characters in a file and replace with meaningful text messages like Hello raka_rjit UNIX for Dummies Questions & Answers 2 08-11-2015 05:28 AM
Help to replace the string with special characters nikhil jain Shell Programming and Scripting 3 02-13-2015 08:16 AM
Replace special characters with backslash and character temp_user Shell Programming and Scripting 3 11-25-2014 12:47 AM
Replace special characters with Escape characters? laknar Shell Programming and Scripting 8 01-06-2012 12:40 AM
Replace special characters ratheeshjulk Shell Programming and Scripting 0 12-22-2011 09:18 PM
How to replace special characters in vi? rogerben Solaris 2 08-03-2011 06:53 AM
Replace new line with <br /> & escape special characters ted_chou12 Shell Programming and Scripting 2 02-07-2011 09:25 PM
Using sed to replace special characters nimo Shell Programming and Scripting 5 08-12-2010 03:42 AM
Single/Multiple Line with Special characters - Find & Replace in Unix Script r_sarnayak Shell Programming and Scripting 0 06-02-2010 03:34 AM
Replace special characters in multiple files - perl RMSoares Shell Programming and Scripting 1 09-01-2009 07:09 PM
Find and replace special characters in a file sujithchandra UNIX for Dummies Questions & Answers 2 10-24-2008 07:59 AM
Help with find and replace w/string containing special characters CAGIRL UNIX for Dummies Questions & Answers 4 10-07-2008 08:13 PM
Replace Special characters in a file solai UNIX for Dummies Questions & Answers 1 07-13-2006 11:36 AM
All times are GMT -4. The time now is 02:39 PM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?