Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-10-2003, 12:08 AM   #1
Registered: Sep 2003
Location: United Kingdom
Distribution: Ubuntu, Arch
Posts: 438

Rep: Reputation: 30
CSV File

Hey all

I have a CSV file that I want to make into a big list, i.e.




What would be the best way to do this, I know I could run the command (a getent for samba), filter it through to one file and then replace with vi but I thought there'd be a better way...

Any ideas would be really helpful
Old 11-10-2003, 01:32 AM   #2
Registered: Aug 2003
Location: Planet Earth
Distribution: Linux Mint Debian Edition (LMDE)
Posts: 215

Rep: Reputation: 31
You can do it with a single sh command line. The following command creates the list by replacing the commas with newlines, and sorts it in asciibetical order:

cat input.csv | sed 's/,/\n/g' | sort
If you want to, you can redirect the output to another file:

cat input.csv | sed 's/,/\n/g' | sort > output.list
Old 11-10-2003, 01:49 AM   #3
Registered: Sep 2003
Location: United Kingdom
Distribution: Ubuntu, Arch
Posts: 438

Original Poster
Rep: Reputation: 30
The power of sed. I've got a couple of scripts with it in but I still haven't figured it out lol :P

Thanks for ur help, worked perfectly


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
Culling Data from a CSV file to output in excel jterr02 Programming 2 05-19-2006 05:58 AM
C++ read csv file row into vector taban1 Programming 3 11-08-2004 03:01 PM
Shell script to read from csv file hendemeg Programming 1 05-11-2004 09:23 PM
csv to fixed-length file roballen Programming 0 03-11-2004 04:12 AM
tar and CSV lhoff Linux - Newbie 1 10-29-2002 01:23 PM > Forums > Non-*NIX Forums > Programming

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