[OT] sed question
Matthew Seaman
m.seaman at infracaninophile.co.uk
Sun Mar 14 14:45:30 PST 2004
On Sun, Mar 14, 2004 at 04:30:40PM -0600, Steven N. Fettig wrote:
> Sorry for posting an off-topic question to the list, but this is
> somethin that has been driving me nuts for weeks now and I can't figure
> it out. I want to pass a text file through sed that replaces all
> whitespaces with a carriage return. I.e., if I have the file
> my_test_text_document.txt that is a few paragraphs of writing, I want to
> take the following input:
>
> I have just written five paragraphs of absolute jibberish and wish that
> I could get sed to work the way that I want. Oh how this question has
> plagued me!
>
> And have sed output:
> I
> have
> just
> written
> five
> paragraphs
> of
> absolute
> jibberish
> and
> ... you get the point.
>
> I can't figure out what the newline character is... I've tried \n \r &\,
> etc. with no avail. I run the following:
>
> sed 's/[ ]/\n/g' my_test_text_document.txt
>
> and the output never has a newline added regardless of what I have
> substituted \n with. I have also used " instead of ' and that hasn't
> helped...
> Sorry for the question, but I'd really appreciate the help!
sed(1) can do it, but it's cleaner and simpler to use tr(1):
% cat foo
I have just written five paragraphs of absolute jibberish and wish that
I could get sed to work the way that I want. Oh how this question has
plagued me!
% tr -s ' ' '\n' < foo
I
have
just
written
five
paragraphs
of
absolute
jibberish
and
wish
that
I
could
get
sed
to
work
the
way
that
I
want.
Oh
how
this
question
has
plagued
me!
Cheers,
Matthew
--
Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks
Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey Marlow
Tel: +44 1628 476614 Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20040314/40b16eaa/attachment.bin
More information about the freebsd-questions
mailing list