LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 09-30-2004, 10:32 PM   #1
rickenbacherus
Member
 
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?

TIA
 
Old 09-30-2004, 10:39 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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


Cheers,
Tink
 
Old 09-30-2004, 10:47 PM   #3
CroMagnon
Member
 
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':
Code:
cat file | tr "\012" ","
(substitute \015 if you actually mean character 13)
 
Old 10-18-2004, 11:23 AM   #4
rickenbacherus
Member
 
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
 
  


Reply



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

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

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