LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   splitting of comma separated values file (horizontal) into a list (vertical ) list (https://www.linuxquestions.org/questions/linux-newbie-8/splitting-of-comma-separated-values-file-horizontal-into-a-list-vertical-list-909166/)

Donoughue 10-20-2011 09:14 AM

splitting of comma separated values file (horizontal) into a list (vertical ) list
 
Hello All,

I am a real newbie at all of this; both *nix and forums so please forgive me if I make any "faux pax's".

Just so you know, this is not some homework, I am way too old I promise! I am starting out in *nix scripting and wanted to know the best was to make a list of values out of a comma separated file, and place the list of values into a new file. So for example:

file1 contains:
dog, cat, mouse, horse, etc

and I would like the following.

file2 will contain:
dog
cat
mouse
horse

any hints, tips greatly appreciated. Thank You!

(btw I checked previous posts but did not find anything relevant.)

AlucardZero 10-20-2011 09:18 AM

Without just giving you the answer:
"tr" can do this. Replace commas with newlines, and optionally remove spaces.

grail 10-20-2011 10:12 AM

Agreed, tr is probably the simplest but tools like sed and awk are also available. Have a look at the man page for each and you should make short work of your problem :)

Donoughue 10-20-2011 01:18 PM

Thanks Guys! I just needed a nudge in the general direction - hope to meet again in the ether sometime :)


All times are GMT -5. The time now is 05:59 PM.