LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Help with csv format needed (http://www.linuxquestions.org/questions/slackware-14/help-with-csv-format-needed-4175498271/)

kite 03-15-2014 03:51 AM

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

mancha 03-15-2014 04:12 AM

Hi.

You can use awk:

Code:

$ awk 'BEGIN {RS=""; FS="\n"} {print $1","$2}' contacts.txt
--mancha

kite 03-15-2014 04:33 AM

Thanks a lot. It works great.


All times are GMT -5. The time now is 05:23 AM.