|
|
|
|
|
by protomikron
1138 days ago
|
|
Some nice stuff, but also some stuff, where things get easier if you just switch to a language with less caveats (like Python). 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? |
|