Parsing Problem

Hi all,
I am having problems parsing the following file:

cat mylist

one,two,three
four
five,six

My goal is to get each number on a seperate line.

one
two
three
four
five
six

I tried this command:

sed -e 's/\,/^M/g' mylist

I get the following output:

three
four
sixe

Any ideas ?

tr ',' '\n' < myFile

Or awk:

awk -v RS='[,\n]' '1' file1

Unfortunately, not all awk-s take RS as a regex. And moreover, not all awk-s take more more than 1 char in RS.
Good idea though :wink:

If I was me, I'd use the tr method :slight_smile:

Sytax error with this command.

---------- Post updated at 07:06 PM ---------- Previous update was at 07:05 PM ----------

tr: too many arguments
Try `tr --help' for more information.

---------- Post updated at 07:06 PM ---------- Previous update was at 07:06 PM ----------

the awk command did work.

xargs -n1 -d, <mylist
sed 's/,/\n/g' mylist
grep -o '[^,]*' mylist

Suffers from the same blank line at the end as

awk -v RS=, '1' file1

(hence the RS=[,\n])

Good idea though :slight_smile:

Getting error:
xargs: invalid option -- d
Usage: xargs [-0prtx] [-e[eof-str]] [-i[replace-str]] [-l[max-lines]]
[-n max-args] [-s max-chars] [-P max-procs] [--null] [--eof[=eof-str]]
[--replace[=replace-str]] [--max-lines[=max-lines]] [--interactive]
[--max-chars=max-chars] [--verbose] [--exit] [--max-procs=max-procs]
[--max-args=max-args] [--no-run-if-empty] [--version] [--help]
[command [initial-arguments]]

Report bugs to <bug-findutils@gnu.org>.

shell returned 1

I'd love to know what OS you're using.

tr and xargs works for me!

I tried sed 's/,/\n/g' mylist
works great, I think I will go with this.
thx to all

---------- Post updated at 07:15 PM ---------- Previous update was at 07:14 PM ----------

Sorry I should have mentioned that, Linux

good for you!

(but like the awk, that sed won't work everywhere)