diff options
Diffstat (limited to 'env/.local/bin/scripts/math')
| -rwxr-xr-x | env/.local/bin/scripts/math | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/env/.local/bin/scripts/math b/env/.local/bin/scripts/math new file mode 100755 index 0000000..26d4854 --- /dev/null +++ b/env/.local/bin/scripts/math @@ -0,0 +1,13 @@ +#!/bin/bash +expression=$1 +precision=$2 + +if [ "$precision" == "" ]; then + precision=1; +fi; + +# Perform arithmetic operation using awk +result=$(awk "BEGIN {printf \"%.${precision}f\n\", $expression}" | sed 's/\.0$//') + +# Print the result +echo "$result" |
