aboutsummaryrefslogtreecommitdiff
path: root/bin/max.awk
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-12-27 18:00:02 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-12-27 18:00:02 +1300
commitc4e80884b5c8ee0e2fbabaa867586d29e1ace9ef (patch)
tree69999e18d91294a2b822b16e2932acacfdb9283a /bin/max.awk
parentMerge branches 'port/bsd/*' (diff)
downloaddotfiles-c4e80884b5c8ee0e2fbabaa867586d29e1ace9ef.tar.gz
dotfiles-c4e80884b5c8ee0e2fbabaa867586d29e1ace9ef.zip
Add max(1df) and min(1df)
Diffstat (limited to 'bin/max.awk')
-rw-r--r--bin/max.awk10
1 files changed, 10 insertions, 0 deletions
diff --git a/bin/max.awk b/bin/max.awk
new file mode 100644
index 00000000..11d4efd9
--- /dev/null
+++ b/bin/max.awk
@@ -0,0 +1,10 @@
+# Get the maximum of a list of numbers
+{
+ if (NR == 1 || $1 > max)
+ max = $1
+}
+END {
+ if (!NR)
+ exit(1)
+ print max
+}