Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usenet!ogicse!dali.cs.montana.edu!rpi!uupsi!jpradley!jpr From: jpr@jpradley.jpr.com (Jean-Pierre Radley) Newsgroups: comp.unix.questions Subject: Re: Convert newlines to something else. Message-ID: <1991Feb10.030329.2094@jpradley.jpr.com> Date: 10 Feb 91 03:03:29 GMT References: <6011@idunno.Princeton.EDU> Reply-To: jpr@jpradley.UUCP (Jean-Pierre Radley) Distribution: usa Organization: NYC Public Unix Lines: 21 In article <6011@idunno.Princeton.EDU> tvz@phoenix.Princeton.EDU (Timothy Van Zandt) writes: >How does one convert newlines to something else in a text file? I cannot >figure out how to do it with sed, if it is possible at all. The problem is that you go crazy trying to type the sed commands from the a shell prompt. You need to go into 'vi' and use the ^V facility to get a true ^M into a script. This script uses sed to either add or delete CR's, depending on how it's called (i.e, store it as addcr, linked to delcr). : # addcr : adds CRs # delcr : removes CRs [ $# -ne 2 ] && echo Usage\: $0 infile outfile && exit case $0 in *addcr) sed s+$+^M+ <$1 >$2;; *delcr) sed s-^M--g <$1 >$2;; esac Jean-Pierre Radley NYC Public Unix jpr@jpradley.jpr.com CIS: 72160,1341