I have a csv file with data as follows
16:47:07,3,r-4-VM,230000000.,0.466028518635,131072,0,0,0,60,0
16:47:11,3,r-4-VM,250000000.,0.50822578824,131072,0,0,0,0,0
16:47:14,3,r-4-VM,240000000.,0.488406067907,131072,0,0,32768,0,0
16:47:17,3,r-4-VM,230000000.,0.467893525702,131072,0,0,0,0,0
I would like to shorten the value in the 5th column.
Desired output
16:47:07,3,r-4-VM,230000000.,0.46,131072,0,0,0,60,0
16:47:11,3,r-4-VM,250000000.,0.50,131072,0,0,0,0,0
16:47:14,3,r-4-VM,240000000.,0.48,131072,0,0,32768,0,0
16:47:17,3,r-4-VM,230000000.,0.46,131072,0,0,0,0,0
Your help is highly appreciated
If rounding is not desired, i.e.
0.466028518635
needs to be printed as0.46
, use:(This can another example of Useless use of cat)
This might work for you (GNU sed):
This replaces the 5th occurence of non-commas to no more than 4 characters length.
You want it in perl, This is it:
tested below:
This will round and print
.47
instead of.46
on the first line, but perhaps that is desirable.Try with this:
So far, the output is at GNU/Linux standard output, so
will send the desired result to
out_filename