LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 03-15-2014, 03:51 AM   #1
kite
Member
 
Registered: Aug 2003
Location: Shenzhen, China
Distribution: Slackware
Posts: 300

Rep: Reputation: 47
Help with csv format needed


Hi folks,

I have a contact list like this:

David
davidcorra@gmail.com

Sam
samy@hotmail.com

Lisa
lisa@abc.com

You could see there is a empty line between each record. Howc an I use bash or any script to turn it to the following commar or tab separated csv format:

David,davidcorra@gmail.com
Sam,samy@hotmail.com
Lisa,lisa@abc.com

Last edited by kite; 03-15-2014 at 03:52 AM. Reason: typo
 
Old 03-15-2014, 04:12 AM   #2
mancha
Member
 
Registered: Aug 2012
Posts: 279

Rep: Reputation: Disabled
Hi.

You can use awk:

Code:
$ awk 'BEGIN {RS=""; FS="\n"} {print $1","$2}' contacts.txt
--mancha
 
3 members found this post helpful.
Old 03-15-2014, 04:33 AM   #3
kite
Member
 
Registered: Aug 2003
Location: Shenzhen, China
Distribution: Slackware
Posts: 300

Original Poster
Rep: Reputation: 47
Thumbs up

Thanks a lot. It works great.
 
  


Reply

Tags
csv


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
How to format .csv file with new data rhbegin Programming 6 11-18-2011 01:43 PM
How-To format output in CSV to match stdout? Linux_Kidd Programming 7 09-29-2011 03:22 PM
So, who want's to help me format a .csv? It'll be fun, promise! pinecone Programming 8 08-09-2010 05:08 PM
[SOLVED] howto: ls output to csv format limdel Linux - Newbie 10 05-19-2010 02:45 AM
Redirect output in .xls or csv format jeesun Programming 5 12-25-2009 05:56 PM


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