The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl: Search for string on line then search and replace text Crypto Shell Programming and Scripting 4 01-04-2008 06:24 AM
Too simple to search for spudtheimpaler UNIX for Dummies Questions & Answers 3 10-21-2006 09:55 AM
Search/Replace with Sed mvalonso UNIX for Dummies Questions & Answers 5 05-08-2006 04:30 PM
Help : Search and Replace ctcuser Shell Programming and Scripting 2 12-02-2004 10:15 AM
Simple? Search replace Brandt UNIX for Dummies Questions & Answers 9 01-16-2004 09:51 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-21-2004
Registered User
 

Join Date: Jan 2004
Posts: 8
Stumble this Post!
Simple Search and Replace - Revisited

I have a ascii file with lines like this:
240|^M\ ^M\^M\ Old Port Marketing order recd $62,664.- to ship 6/22/99^M\

when this record gets loaded into my database, the \ is stored literally and so the user sees carriage return \ (hex 0D 5C) when what i need is carriage return line feed (hex 0D 0A).

any ideas on how i can accomplish this with sed?





P. S. awhile back, Perderabo wrote this sed script for me

#! /usr/bin/sed -nf
#
#
s/^M\\$/^M\\/
H
t
x
s/\n//g
p
s/.*//
h

which altered a files like this:

240|^M\
^M\
^M\
Old Port Marketing order recd $62,664.- to ship 6/22/99^M\


to look like this:

240|^M\ ^M\^M\ Old Port Marketing order recd $62,664.- to ship 6/22/99^M\
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-23-2004
oombera's Avatar
Have a day :|
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
Stumble this Post!
How about just reversing what his script did then? If the only time a backslash character shows up is right after a carriage return character, try:

sed 's/\\/\n/g' yourFile > anotherFile
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0