replace carriage returns - the final solution

Richard D. Williams richard at appgrp.net
Wed Jul 7 08:20:51 PDT 2004


Thanks to all and a special thanks to Ted Dodd.

Here is what I ended up doing.

# remove any nul
tr -d '\000' < $1 > $1.nul
# remove any ~
sed 's/~//g' < $1.nul > $1.sed
#remove any carriage-returns
tr -d '\r' < $1.sed > $1.ncr
#remove any line feeds
tr -d '\n' < $1.ncr > $1.new
#clean up
rm $1.nul $1.sed $1.ncr
#move result to my working area to be imported
mv $1.new /appl/servefx/shared/working


Richard D. Williams


Ted B Dodd wrote:

>cat filename | tr "\015" "~"
>
>That should have worked, eh?
>
>sed 's/^M//g' < filename > filename.new
>
>That ^M is a control-M.
>
>Try this in vi the first time to see if it will work for you.  
>If you know vi, forgive the tutorial
>
>vi filename <ENTER>
>:1,$s/CTRL-V then CTRL-M//g <ENTER>
>:x <ENTER>
>
>You use CTRL-V to make the next charater show up right.  
>
>Let me know how it goes.  If the sed works, you can create a 
>short script that does the work for you.  If you are using SCO, 
>the "dtox" command should also work as in: 
>
>"dtox filename > filename.new"
>
>On 6 Jul 2004 at 16:46, Richard D. Williams wrote:
>
>  
>
>>Oops, tr has no replace functionality. maybe a little sed ight 
>>be in order.
>>
>>Can sed replace ~@~ with ~?
>>
>>Richard
>>
>>teddodd at comcast.net wrote:
>>    I am confused.  Is this Unix?  If so, who created the mysql database export?  Do you have a file created by mysql to import?  Does every record have this offensive CR? If so, would a little sed script work for you?
>>    
>>    Ted B
>>    
>>    
>>      
>>    When importing data from a mysql database, is there any way in filepro 
>>    to find and replace a carriage-return in a field?
>>    
>>    I can nont get the programmer I am dealing with to do it on his end.
>>    
>>    All comments welcome as usual,
>>    
>>    Richard D. Williams
>>    The Applications Group
>>    
>>    _______________________________________________
>>    Filepro-list mailing list
>>    Filepro-list at lists.celestial.com
>>    http://mailman.celestial.com/mailman/listinfo/filepro-list
>>        
>>    
>>    
>>    
>>      
>>    
>>
>
>
>
>
>
>  
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.celestial.com/pipermail/filepro-list/attachments/20040707/0758a155/attachment.html


More information about the Filepro-list mailing list