From bbf01d8a60d7869ef5cf9cbc0baf06b222b9dab1 Mon Sep 17 00:00:00 2001 From: olli Date: Tue, 17 Jan 2023 09:07:10 +0100 Subject: [PATCH] =?UTF-8?q?=E2=80=9Egaboshlib/g=5Fpercentage-diff.bashfunc?= =?UTF-8?q?=E2=80=9C=20hinzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gaboshlib/g_percentage-diff.bashfunc | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 gaboshlib/g_percentage-diff.bashfunc diff --git a/gaboshlib/g_percentage-diff.bashfunc b/gaboshlib/g_percentage-diff.bashfunc new file mode 100644 index 0000000..091bc9b --- /dev/null +++ b/gaboshlib/g_percentage-diff.bashfunc @@ -0,0 +1,8 @@ +#!/bin/bash + +function g_percentage-diff { + local g_from=$1 + local g_to=$2 + local g_diff=$(echo "scale=8; $g_to-$g_from" | bc | sed 's/^\./0./; s/^-\./-0./') + echo "scale=8; 100/$g_from*$g_diff" | bc | sed 's/^\./0./; s/^-\./-0./' +}