On macOS, `tr '[:lower:]' '[:upper:]' < export.csv` fails with `tr: Illegal byte sequence`, and `sed` gives `sed: RE error: illegal byte sequence`.
IntermediateTroubleshootingTroubleshooting: tools, portability, permissions and environment
Answer
Likely causes → The file is not valid UTF-8 (often Latin-1 or Windows-1252 exported from a spreadsheet), and the locale is UTF-8, so the tools refuse bytes that are not valid characters.
Diagnose →
file -I export.csv # charset=iso-8859-1
iconv -f UTF-8 -t UTF-8 export.csv > /dev/null # reports the first invalid byte position
Fix → Convert the encoding, or process as raw bytes:
iconv -f WINDOWS-1252 -t UTF-8 export.csv > export.utf8.csv
LC_ALL=C tr '[:lower:]' '[:upper:]' < export.csv
Prevent → Normalise encoding at ingestion (iconv once), and set LC_ALL=C in scripts that treat data as bytes.
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