An `awk` one-liner works on your RHEL box but fails on Ubuntu with `awk: line 1: function gensub never defined`.
IntermediateTroubleshootingTroubleshooting: tools, portability, permissions and environment
Answer
Likely causes → gensub() (also asort(), PROCINFO, true multidimensional arrays) is a gawk extension. RHEL's awk is gawk; Ubuntu and Debian default to mawk, and Alpine uses BusyBox awk.
Diagnose →
readlink -f "$(command -v awk)" # /usr/bin/mawk
awk -W version 2>/dev/null | head -1 # mawk prints its version this way
Fix → Use POSIX functions (sub, gsub, match, substr), or call gawk explicitly and declare it as a dependency:
# gensub(/([0-9]+)ms/, "\\1", "g") rewritten portably:
awk '{ gsub(/ms/, "", $5); print $5 }' access.log
command -v gawk >/dev/null || die "gawk is required (apt-get install gawk)"
Prevent → Write POSIX awk unless the script checks for gawk up front; test in the target distro's container.
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`.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`.BeginnerOn macOS, `tr '[:lower:]' '[:upper:]' < export.csv` fails with `tr: Illegal byte sequence`, and `sed` gives `sed: RE error: illegal byte sequence`.Intermediate