`comm -23 expected.txt installed.txt` prints `comm: file 1 is not in sorted order`, even though both files were produced with `sort`.
IntermediateTroubleshootingTroubleshooting: tools, portability, permissions and environment
Answer
Likely causes → The files were sorted under different locales (for example one on a laptop with en_US.UTF-8, one in cron with C), or with different options (sort -f). comm and join compare using the current locale's collation and detect the mismatch.
Diagnose →
locale | grep -E 'LC_COLLATE|LANG'
LC_ALL=C sort -c expected.txt; LC_ALL=C sort -c installed.txt # -c checks order
Fix → Sort and compare under the same, explicit locale:
export LC_ALL=C
comm -23 <(sort -u expected.txt) <(sort -u installed.txt)
Prevent → Set LC_ALL=C (byte order, fast and stable) at the top of scripts that sort, compare or use character ranges like [a-z].
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`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