home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] sed

Chris h wrote:
Sample data:

2 45.388,889  -75.872,019 waypoint.wpt1 0 0 0 0
3 45.396,796  -75.885,759 waypoint.wpt1 0 0 0 0
4 45.405,001  -75.902,138 waypoint.wpt1 0 0 0 0

desired output;

2, 45.388,889, -75.872,019, waypoint.wpt1, 0 0 0 0
3, 45.396,796,  -75.885,759, waypoint.wpt1, 0 0 0 0
4, 45.405,001,  -75.902,138, waypoint.wpt1, 0 0 0 0

now wrt to the "0" coordinates whether they are comma separated or not is not important.

If you want the zeros not to be comma-separated and are not averse to using Perl, this will also do the trick:

	perl -ne'print join ", " => split " ", $_, 5'


The third argument of 'split' restricts the number of fields to at most that number, which in this case means that the zeros will not get split apart.

Joy,
`/anick





replies

references

message navigation