menuimage

Description

Options

Examples

Dependencies

License

Changelog

Download

Donation

My_Other_Sites

My_Programs

Comments

numliststat v0.6.0 [05 Jan 2026] by Dominic

Description

Returns statistical value(s) for a piped-in list of numbers - integers or decimals, space or line-separated. 6 values (sum count mean median minimum maximum) are output, columnised with a descriptive header;
or if one or more of these are added as parameters (case-insensitive and only the first three letters are significant, tot(al) can be used instead of sum and ave(rage) instead of mean) then only the specified
value(s) are output, with no header or columnising.

Note the optional -p setting for the maximum number of decimal places in each output result (default: 4). Unless the -m setting is used, results are shown with as few decimal places as possible that give an
accurate result, subject to the maximum setting (but the calculations are at a much higher level of precision).

Options

-f - do not show help on null input
-h - see this help
-m - always show the maximum number of decimal places even when not required i.e. with trailing zero(es)
-p n - show a maximum of n decimal places for output value(s) (default: 4)
-l - see changelog

Examples

$ echo "1 2 3 4 5 10"|numliststat.sh
sum count mean median minimum maximum
25 6 4.1667 3.5 1 10
$ echo "1 2 3 4 5 10"|numliststat.sh mean minimum max
4.1667 1 10

Dependencies

awk bash column fold sed

License

Copyright © 2026 Dominic Raferd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License
at https://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Changelog

0.6 [05 Jan 2026] - add -f option
0.5 [16 Dec 2025] - show help on invalid or missing input
0.4 [30 Jul 2024] - add -m option
0.3 [12 Jun 2024] - work with null input (output all zeroes)
0.2 [08 Dec 2022] - bugfix showing full decimal results, add -p option, ignore commas or CRs in input, conform with shellcheck, publish
0.1 [08 Jan 2022] - based on an answer at https://unix.stackexchange.com/questions/13731/is-there-a-way-to-get-the-min-max-median-and-average-of-a-list-of-numbers-in

Download numliststat.sh

Donation

I have provided this software free gratis and for nothing. If you would like to thank me with a contribution, please let me know and I will send you a link. Thank you!

My Other Sites

My Programs

Here is a selection of some (other) programs I have written, most of which run under GNU/Linux from the command line (CLI), are freely available and can be obtained by clicking on the links. Dependencies are shown and while in most cases written and tested on an x86-based Linux server, they should run on a Raspberry Pi, and many can run under Windows using Windows Subsystem for Linux (WSL) or Cygwin. Email me if you have problems or questions, or if you think I could help with a programming requirement.

Backup Utilities

Debian/Ubuntu kernel and LVM Utilities

Miscellaneous Programs

Comments

This section is closed. If you have a question, please submit it by email, thank you.

No comments yet for '/programs/help/numliststat.sh.php'