(no title)
protomikron | 2 years ago
My rule of thumb is to use Bash to write simple scripts, if they fit on the command line and have just one level of loop or if-else (lines can get very long, though ...). However for more complicated stuff I use the alternative programs (find, sed, awk, ...), as they behave more predictable.
Furthermore I am not sure one should use such simplified versions, that are just wrong:
is_float() {
# Usage: is_float "number"
# The test checks to see that the input contains
# a '.'. This filters out whole numbers.
[ -z "${1##*.*}" ] &&
printf %f "$1" >/dev/null 2>&1
}
I mean having a '.' in the string does make it a non-integer, but what about other floats like 2e3?
tlamponi|2 years ago
protomikron|2 years ago
You are of course correct (sorry to sound like a language model), I missed the printf.