rob11g
1
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 ?
Scott
3
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
Scott
5
If I was me, I'd use the tr method
rob11g
6
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.
Scott
8
Suffers from the same blank line at the end as
awk -v RS=, '1' file1
(hence the RS=[,\n])
Good idea though
rob11g
9
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
Scott
10
I'd love to know what OS you're using.
tr and xargs works for me!
rob11g
11
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
Scott
12
good for you!
(but like the awk, that sed won't work everywhere)