bin/=: properly convert number formats

This commit is contained in:
xeruf 2022-09-12 12:50:31 +02:00
parent c5fcb1d3a8
commit 8ab21c3fd9
1 changed files with 4 additions and 4 deletions

View File

@ -1,5 +1,5 @@
#!/bin/bash
#!/bin/bash -ex
# Shortcut for mathematical calculations
# Assumes german numbers as in 1.000,5
calc="$(echo "$@" | sed -e 's/p/+/g' -e 's/\.//g' -e 's/,/./g' -e 's/x/*/g' -e 's/m/-/g')"
bc -l <<<"scale=10;$calc" | sed 's/0\+$/0/'
# Converts german numbers such as 1.000,5
calc="$(echo "$@" | sed -e 's/p/+/g' -e 's/\.\(.*,\)/\1/g' -e 's/,/./g' -e 's/x/*/g' -e 's/m/-/g')"
bc -l <<<"scale=10;$calc" | sed 's/\(\..*\)0\+$/\10/'