LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-15-2003, 06:13 PM   #1
Harpune
Member
 
Registered: Sep 2002
Location: Seattle, WA
Distribution: Ubuntu
Posts: 101

Rep: Reputation: 15
using sed to remove word wrap


I have a file that was previously formatted with word wrap such that it has a newline at a certain row length, like this:

***

`Thank you, it's a very interesting dance to watch,' said
Alice, feeling very glad that it was over at last: `and I do so
like that curious song about the whiting!'

`Oh, as to the whiting,' said the Mock Turtle, `they--you've
seen them, of course?'

`Yes,' said Alice, `I've often seen them at dinn--' she
checked herself hastily.

`I don't know where Dinn may be,' said the Mock Turtle, `but
if you've seen them so often, of course you know what they're
like.'

`I believe so,' Alice replied thoughtfully. `They have their
tails in their mouths--and they're all over crumbs.'

`You're wrong about the crumbs,' said the Mock Turtle:
`crumbs would all wash off in the sea. But they HAVE their tails
in their mouths; and the reason is--' here the Mock Turtle
yawned and shut his eyes.--`Tell her about the reason and all
that,' he said to the Gryphon.

`The reason is,' said the Gryphon, `that they WOULD go with
the lobsters to the dance. So they got thrown out to sea. So
they had to fall a long way. So they got their tails fast in
their mouths. So they couldn't get them out again. That's all.'

***

Is there a way to use sed, or another editor to automatically remove this newline so that each paragraph is on it's own line?

thanks,
 
Old 10-16-2003, 02:37 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Try this out (probably an easier way - I just can't think of it):
Code:
cat /path/to/file | echo -n `sed 's/^$/STARTPARA/'`|sed 's/STARTPARA/\n\n/g'
 
Old 03-02-2009, 06:53 PM   #3
A.Thyssen
Member
 
Registered: May 2006
Location: Brisbane, Australia
Distribution: linux
Posts: 158

Rep: Reputation: 44
Quote:
Originally Posted by david_ross View Post
Try this out (probably an easier way - I just can't think of it):
Code:
cat /path/to/file | echo -n `sed 's/^$/STARTPARA/'`|sed 's/STARTPARA/\n\n/g'
Try this for a single paragraph

Code:
tr -s ' \009\012' ' '
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
restricted word wrap with Kontact (Kmail) blastradius Linux - Software 2 10-21-2005 07:39 AM
Microsoft Word won't word wrap Micro420 General 1 06-13-2005 04:36 PM
word wrap in java linux_ub Programming 3 08-11-2004 01:16 AM
Word Wrap Squall LQ Suggestions & Feedback 4 02-03-2004 03:25 PM
sed help, replacing a letter with a word GridX Linux - Newbie 1 09-24-2003 10:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration