embarassing/frustrating sed question

From: Christopher C. Stevenson <csteven_at_kelvin.physics.mun.ca>
Date: Wed, 25 Nov 1998 17:54:44 -0330 (NST)

Greetings,

Sed is not completely unknown to me, but today I tried using it
to substitute newlines for ^M's in a Postscript printjob originating
from a Mac (which has no linefeeds, causing things like 'awk' and 'vi' to
choke on too-long lines if you try to manipulate them), and am having
trouble getting sed to spit out literal \n's. This is under DU 4.0B.

I first tried

        sed 's/^M/\n/g' mac.ps

which substituted simple "n's". (Note that CTRL-V-CTRL-M is how you
specify the literal ^M. Saddly, on this keyboard, I can't specify a
literal LF). Then I tried a few more;

        sed 's/^M/"\010"/g' mac.ps -substitutes "010" for ^M's
        sed 's/^M/"\n"/g' mac.ps -"n" again
        sed s/^M/\\n/g mac.ps -and again...
        (etc)

None of these work, I've run out of delimiters to try, any number of
backslashes seem to be ignored, I can't seem to tell sed what character to
print as I can (trivially) awk or echo by specifying "\123" whatever...
there must be something I've missed.

Any ideas at all? This is perhaps even more annoying because it
should take only a moment to do, but now has me pulling my hair
out. I'll summarize.

Cheers
Chris
======================================================================

Christopher C Stevenson C3004 office: (709) 737-2624
Dept. of Physics & Physical Oceanography fax: (709) 737-8739
Memorial University of Newfoundland
St. John's, Newfoundland, CANADA A1B 3X7
URL: http://www.physics.mun.ca/~csteven
======================================================================
Received on Wed Nov 25 1998 - 21:25:43 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:38 NZDT