replace carriage returns - the final solution

Jay R. Ashworth jra at baylink.com
Wed Jul 7 08:28:20 PDT 2004


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
-- 
Jay R. Ashworth                                                jra at baylink.com
Designer                          Baylink                             RFC 2100
Ashworth & Associates        The Things I Think                        '87 e24
St Petersburg FL USA      http://baylink.pitas.com             +1 727 647 1274

	"You know: I'm a fan of photosynthesis as much as the next guy,
	but if God merely wanted us to smell the flowers, he wouldn't 
	have invented a 3GHz microprocessor and a 3D graphics board."
					-- Luke Girardi


More information about the Filepro-list mailing list