Home Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

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

# 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

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 03:04 AM
Help to replace the string with special characters nikhil jain Shell Programming and Scripting 3 02-13-2015 07:16 AM
Replace special characters with Escape characters? laknar Shell Programming and Scripting 8 01-05-2012 11:40 PM
Replace special characters ratheeshjulk Shell Programming and Scripting 0 12-22-2011 08:18 PM
How to replace special characters in vi? rogerben Solaris 2 08-03-2011 05:53 AM
Replace new line with <br /> & escape special characters ted_chou12 Shell Programming and Scripting 2 02-07-2011 08:25 PM
Using sed to replace special characters nimo Shell Programming and Scripting 5 08-12-2010 02:42 AM
Find and replace special characters in a file sujithchandra UNIX for Dummies Questions & Answers 2 10-24-2008 06:59 AM
Help with find and replace w/string containing special characters CAGIRL UNIX for Dummies Questions & Answers 4 10-07-2008 07:13 PM
Replace Special characters in a file solai UNIX for Dummies Questions & Answers 1 07-13-2006 10:36 AM


All times are GMT -4. The time now is 05:56 AM.

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