Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 09-30-2004, 10:32 PM   #1
Registered: Mar 2003
Location: colorado springs. colorado
Distribution: Debian-Sid 2.6.24-rt1
Posts: 290

Rep: Reputation: 30
List format conversion

I need to convert a carriage return seperated list into a comma seperated list. Any idea how I might go about such a thing?

Old 09-30-2004, 10:39 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Something like
awk 'BEGIN{RS="\n";ORS=","} {print $0 }' <filename>

Old 09-30-2004, 10:47 PM   #3
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
Hmmm, some more details might be useful.

Do you want to convert EVERY carriage return into a comma, or should there be x number of values per comma separated line, with carriage returns at the end of each line?

The former could be accomplished with 'tr':
cat file | tr "\012" ","
(substitute \015 if you actually mean character 13)
Old 10-18-2004, 11:23 AM   #4
Registered: Mar 2003
Location: colorado springs. colorado
Distribution: Debian-Sid 2.6.24-rt1
Posts: 290

Original Poster
Rep: Reputation: 30
Thanks for the input guys. What I ended up doing was this:
perl -pe 's/\n/,/m' inputlist >outputfile


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
Conversion to .DST format ( embroidery ) Relativity Linux - Software 13 02-22-2014 11:10 AM
OpenOffice 2.0 file-format conversion nycace36 Linux - Software 5 10-18-2006 08:44 AM
sources.list entry format for suse 9.2.9 repository TomF SUSE / openSUSE 4 04-06-2005 04:49 PM
Conversion of outlook .pst file into any Linux mail client format Mayuresh Linux - Software 1 08-09-2004 10:52 AM
How to list the files using less pager in colored format? phoe6 Linux - Newbie 1 02-05-2004 02:39 PM

All times are GMT -5. The time now is 02:49 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration