LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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, 04:51 AM   #1
kite
Member
 
Registered: Aug 2003
Location: Shenzhen, China
Distribution: Slackware
Posts: 301

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 04:52 AM. Reason: typo
 
Old 03-15-2014, 05:12 AM   #2
mancha
Member
 
Registered: Aug 2012
Posts: 362

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, 05:33 AM   #3
kite
Member
 
Registered: Aug 2003
Location: Shenzhen, China
Distribution: Slackware
Posts: 301

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


All times are GMT -5. The time now is 01:47 AM.

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