inserting CR/LF

Dik T. Winter dik at cwi.nl
Sat May 18 10:19:10 AEST 1991


In article <1060 at dri500.dri.nl> slootman at dri.nl (Paul Slootman) writes:
 > img at eng.cam.ac.uk (Ian Green) writes:
 > >I want to replace all occurences of LF in a file with the
 > >sequence CR-LF.
 > Use this:
 > sed `echo 's,$,\r,'` < input > output
The SysV solution.  Not all echo's interpret \r.  Portable (I think):
	<input sed s,'$',`echo a | tr a '\015'`, >output
If your system + shell allow quoting through ^V:
	<input sed s,'$',^V^M, >output
(here ^V is ctrl-v, ^M is ctrl-m or return).  BSD and BSD derived systems
do allow ^V quoting in general, but not with all shells.  A notable exception
is the Korn shell.  How do I quote a return in the Korn shell?
--
dik t. winter, cwi, amsterdam, nederland
dik at cwi.nl



More information about the Comp.unix.wizards mailing list