LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-18-2006, 11:04 PM   #1
sadarax
Member
 
Registered: Sep 2005
Distribution: Ubuntu
Posts: 249

Rep: Reputation: 30
SED newline usage question -- I think


I am trying get a large text file with lines like this:

Quote:
His scream of agony echoed off the uncaring stones.
Chapter One
William dropped his book with a disgusted sigh and looked at
To end up like this:

Quote:
His scream of agony echoed off the uncaring stones.

Chapter One

William dropped his book with a disgusted sigh and looked at
Basically I want to add an extra blank line after every blank line. I have tried using something like this:

Code:
cat file.txt | sed -r s/\n/\n\n/ > newfile.txt
But it does not seem to work. Any suggestions? The solution does not necessarily have to involve using sed.
 
Old 02-18-2006, 11:22 PM   #2
kevkim55
Member
 
Registered: Dec 2005
Location: Edmonton
Distribution: BLFS, Gentoo
Posts: 353

Rep: Reputation: 32
Not sure 'bout this though ! Try using tr
 
Old 02-18-2006, 11:27 PM   #3
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 327Reputation: 327Reputation: 327Reputation: 327
cat file.txt | sed -e 's/$/\n/' > newfile.txt
 
Old 02-18-2006, 11:50 PM   #4
sadarax
Member
 
Registered: Sep 2005
Distribution: Ubuntu
Posts: 249

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by macemoneta
cat file.txt | sed -e 's/$/\n/' > newfile.txt
Thanks, that did it.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sed: insert a newline. Why does not it work? J_Szucs Linux - Software 4 03-19-2014 01:28 PM
sed question ckoniecny Linux - General 3 11-11-2005 09:31 AM
sed usage(only repace one occurance) feetyouwell Linux - Software 7 01-31-2005 02:25 PM
sed usage(only repace one occurance) feetyouwell Linux - Software 2 01-31-2005 04:08 AM
how to determine cpu usage, memory usage, I/O usage by a particular user logged on li rags2k Programming 4 08-21-2004 04:45 AM


All times are GMT -5. The time now is 10:48 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration