Skip to main content
17 events
when toggle format what by license comment
Sep 4, 2022 at 5:26 answer added Apekool timeline score: 1
May 16, 2022 at 21:27 history became hot network question
May 16, 2022 at 20:43 comment added ilkkachu as an aside, the standard way to declare a function is dec_to_int(), without the function keyword (it's a ksh thing), and while Bash supports it too, not all shells might (e.g. Dash and Busybox don't), and there's no upside. Also, if you're on Bash, you can use printf -v SCALED_INT "%.0f\n" "${DECIMAL}e${SCALE_FACTOR}" instead of SCALED_INT=$(printf ...), it saves spawning a copy of the shell for the command substitution.
May 16, 2022 at 18:55 vote accept William
May 16, 2022 at 18:55 history edited William CC BY-SA 4.0
Added solution used
May 16, 2022 at 16:00 answer added ilkkachu timeline score: 3
May 16, 2022 at 15:33 answer added Bodo timeline score: 4
May 16, 2022 at 13:57 comment added jesse_b You can just compare the numbers as is with awk. awk -v load1_int="$load1_int" -v crit_load_int="$crit_load_int" 'BEGIN{if (load1_int > crit_load_int) { ... }}'
May 16, 2022 at 13:49 comment added doneal24 awk is probably your best bet but you can turn a decimal to a scaled integer with printf "%.2f" 3.5 | tr -d ..
May 16, 2022 at 13:48 comment added William My system has awk and gnu sed both, those or printf seemed like it might be the option that could move the decimal point over (and possibly 0 pad the end if needed) but I haven't been able to come up with something that works. That's a great catch on the decimal point only working if it has a value in the hundreths place as well, I can fix that with another conditional but this is just further evidence to me that I need to simplify this by moving the decimal point to the right two places.
May 16, 2022 at 13:42 comment added Bodo Your numerical comparison of the DECIMAL part works only if the number of decimal digits is the same. When you have e.g. 3.5 and 3.25, you might get an unexpected result if you compare 5 with 25.
May 16, 2022 at 13:41 comment added Romeo Ninov @StéphaneChazelas, even Debian have awk installed :D
May 16, 2022 at 13:38 comment added Stéphane Chazelas @jesse_b even Debian doesn't have bc installed out of the box. See also pax and m4 which are often omitted.
May 16, 2022 at 13:33 comment added Kusalananda Wouldn't this be a matter of testing against ^(3\.[6-9]|[4-9]\.|[0-9]{2,}\.)? Or something similar.
May 16, 2022 at 13:29 comment added jesse_b Does your system have awk, perl, python, nodejs, ruby, zsh?
S May 16, 2022 at 13:26 review First questions
May 16, 2022 at 14:58
S May 16, 2022 at 13:26 history asked William CC BY-SA 4.0