LinuxQuestions.org
Review your favorite Linux distribution.
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 11-10-2010, 11:48 AM   #1
jasonws
LQ Newbie
 
Registered: Oct 2010
Location: Vermont, USA
Posts: 15

Rep: Reputation: 0
How to remove line breaks from lines ending with a comma


Hi, I have a CSV file that's created in an application that can't output lines longer than 250 characters. Unfortunately, the data fields, all together, are longer than this. how would I remove the line break from every line that ends with a comma?

For example:
A,B,C
D,E,
F
G,H,I

becomes:
A,B,C
D,E,F
G,H,I

Thanks!
 
Old 11-10-2010, 12:03 PM   #2
jasonws
LQ Newbie
 
Registered: Oct 2010
Location: Vermont, USA
Posts: 15

Original Poster
Rep: Reputation: 0
Nevermind. I found this Concatenating the two lines in a file where any line starting with a comma joins the previous line. I particularly liked the sed solution:
Quote:
sed -e 'H;$!d;x;s/\n,/,/g' file > newfile
 
  


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
Add comma to end of lines in text file Johng Programming 9 08-21-2010 04:15 AM
[SOLVED] vim remove line breaks ColInvictus Linux - Newbie 3 09-27-2009 08:10 PM
using sed to remove line in a comma-delimited file seefor Programming 4 03-10-2009 03:35 PM
Need a script to remove last comma in a file jgombos Programming 15 01-14-2008 01:30 PM
Need REG EXP Help to remove line breaks webshark Programming 18 07-08-2005 04:31 PM

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

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