slootman@dri.nl (Paul Slootman) (05/18/91)
img@eng.cam.ac.uk (Ian Green) writes: >I want to replace all occurences of LF in a file with the >sequence CR-LF. > >I have tried and failed with tr and sed. It must be easy! (I don't >want to write code/use emacs or vi.) Use this: sed `echo 's,$,\r,'` < input > output That should do it. The trouble you probably had was entering the carriage return (\r) directly; it gets turned into a newline (\n) by the Unix terminal handler. Paul.
dik@cwi.nl (Dik T. Winter) (05/18/91)
In article <1060@dri500.dri.nl> slootman@dri.nl (Paul Slootman) writes: > img@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@cwi.nl