LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-19-2006, 12:04 AM   #1
sadarax
Member
 
Registered: Sep 2005
Distribution: Ubuntu
Posts: 252

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-19-2006, 12:22 AM   #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-19-2006, 12:27 AM   #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: 344Reputation: 344Reputation: 344Reputation: 344
cat file.txt | sed -e 's/$/\n/' > newfile.txt
 
Old 02-19-2006, 12:50 AM   #4
sadarax
Member
 
Registered: Sep 2005
Distribution: Ubuntu
Posts: 252

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 5 06-14-2019 09:18 AM
sed question ckoniecny Linux - General 3 11-11-2005 10:31 AM
sed usage(only repace one occurance) feetyouwell Linux - Software 7 01-31-2005 03:25 PM
sed usage(only repace one occurance) feetyouwell Linux - Software 2 01-31-2005 05: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 05:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:46 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