Convert newlines to something else.
Tom Christiansen
tchrist at convex.COM
Fri Feb 8 04:19:42 AEST 1991
>From the keyboard of tvz at phoenix.Princeton.EDU (Timothy Van Zandt):
: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.
Dealing with \n's in sed is not as straightforward as you might wish.
Maybe someone will post a sed solution.
I would use the tr program if you want single char translations, like
perhaps
% tr '\012' '/' <infile >outfile
If you want more complex changes, I would use perl, perhaps like this:
% perl -pe 's/\n/foobar /' <infile >outfile
--tom
--
"Still waiting to read alt.fan.dan-bernstein using DBWM, Dan's own AI window
manager, which argues with you for 10 weeks before resizing your window."
### And now for the question of the month: How do you spell relief? Answer:
U=brnstnd at kramden.acf.nyu.edu; echo "/From: $U/h:j" >>~/News/KILL; expire -f $U
More information about the Comp.unix.questions
mailing list