replace carriage returns - the final solution

Richard D. Williams richard at appgrp.net
Wed Jul 7 09:14:16 PDT 2004


Jay,

That does look more efficient. I will try it as well.

I actual changed the sed line to:   sed 's/~@//g' < $1.ul > $1.sed

Each line ends with ~@~crnl (carriage-return line-feed), so when I remove the ~@ it leaves the ~.
I use it as my end-of-record marker and use an import of: import ascii merge = (filename) r=~ f=|

This works fine.

Richard D. Williams


Jay R. Ashworth wrote:

>On Wed, Jul 07, 2004 at 10:20:51AM -0500, Richard D. Williams wrote:
>  
>
>>   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
>>    
>>
>
>That's easier to read, certainly... but it's probably more efficient to
>do it as a pipeline:
>
>cat $1 |
>  tr -d '\000' |
>  sed 's/~//g' |
>  tr -d '\r' |
>  tr -d '\n' |
>  cat >/appl/servefx/shared/working/$1
> 
>But, fwiw -- I assume you're bringing this in as a fixed length alien
>file -- I've found in the past that it's quite a bit easier to just put 
>
>CRLF,2,* 
>
>at the end of my maps (or at the very least, LF,1,*), and leave the
>intermediate file in a format I can edit comfortably with vi.
>
>Wait: you're stripping random nulls & tildes, which means you *can't* be in
>fixed-length mode: how are you coping if you yank the linefeed, too?
>
>Cheers,
>-- jra
>  
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.celestial.com/pipermail/filepro-list/attachments/20040707/671a1972/attachment.html


More information about the Filepro-list mailing list