A load check fails with `bash: ((: 4.75: syntax error: invalid arithmetic operator (error token is ".75")`.
BeginnerTroubleshootingTroubleshooting: tools, portability, permissions and environment
Answer
Likely causes → Bash arithmetic is integer-only. /proc/loadavg, bc output and many metrics are decimals, which (( )) and [ -gt ] cannot handle.
Diagnose → cat /proc/loadavg shows values like 4.75 3.10 2.02.
Fix → Compare in awk, which uses floating point, and return the result as an exit status:
read -r load1 _ < /proc/loadavg
cores=$(nproc)
if awk -v l="$load1" -v c="$cores" 'BEGIN { exit !(l > c * 1.5) }'; then
alert WARNING "load $load1 on $cores cores"
fi
Prevent → Do decimal maths in awk, and keep integers in Bash (percentages without %, bytes, seconds).
More on Troubleshooting: tools, portability, permissions and environment
On a Mac, `sed -i 's/replicas: 2/replicas: 3/' deploy.yaml` fails with `sed: 1: "deploy.yaml": extra characters at the end of d command`.BeginnerA cleanup script fails on a developer's Mac with `date: illegal option -- d`.BeginnerA script that works on Ubuntu fails in an Alpine-based CI image with `grep: unrecognized option: P`.IntermediateAn `awk` one-liner works on your RHEL box but fails on Ubuntu with `awk: line 1: function gensub never defined`.Intermediate`comm -23 expected.txt installed.txt` prints `comm: file 1 is not in sorted order`, even though both files were produced with `sort`.Intermediate`grep ERROR /var/log/app/app.log` prints only `grep: /var/log/app/app.log: binary file matches`.Beginner