[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: datamash 1.7 rounding to integer
From: |
Erik Auerswald |
Subject: |
Re: datamash 1.7 rounding to integer |
Date: |
Wed, 10 Mar 2021 16:32:05 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hi,
On Wed, Mar 10, 2021 at 09:41:48AM -0500, John Rhee wrote:
> Love the app. I wonder if you can enable "-R0" option to round calculation
> outputs (ex. mean) to integer?
You can combine different datamash invocations:
$ seq 10 | datamash mean 1
5.5
$ seq 10 | datamash mean 1 | datamash round 1
6
> I see there's a --format option, but I couldn't find a working example
> anywhere. I've unsuccessfully tried --format="%i" and such.
You could try something like --format='%.0f'. This works for printf,
and the manual says:
--format=FORMAT
print numeric values with printf style floating-point FORMAT
Example with printf:
$ printf '%f %.0f\n' 5.5 5.5
5.500000 6
HTH,
Erik
--
The laws of mathematics are very commendable, but the only law that
applies in Australia is the law of Australia.
-- Australian Prime Minister Malcolm Turnbull