[OT] sed question

Steven N. Fettig freebsd at stevenfettig.com
Sun Mar 14 14:31:04 PST 2004


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!

Steve Fettig




More information about the freebsd-questions mailing list