xz02
asked on
Can sed do this?
I have a csv file like this:
1.3,2.4,4.5
4.0,6.77,3.21
.....
data is delimited by comma, how can I filter out the first and third data on each line
and save into a seperate line?
Thanks.
1.3,2.4,4.5
4.0,6.77,3.21
.....
data is delimited by comma, how can I filter out the first and third data on each line
and save into a seperate line?
Thanks.
Or do you mean something more like this?
sed -e h -e 's/[^,]*,\([^,]*\),[^,]*/\ 1/p' -e g -e 's/,[^,]*,/,/'
sed -e h -e 's/[^,]*,\([^,]*\),[^,]*/\
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I would do a
cat infile | cut -d, -f1,3 | tr " " "\012" >outfile
which should filter out the first and third column separated by
commas and separate them afterwards by a newline...
cat infile | cut -d, -f1,3 | tr " " "\012" >outfile
which should filter out the first and third column separated by
commas and separate them afterwards by a newline...
sed -e 's/,[^,]*,/,/' < csvfile > seperatefile