GNU, BSD and BusyBox utility differences
Bash is a shell; tools such as stat, sed and find are separate executables. Their options and output formats vary across GNU, BSD/macOS and BusyBox builds. GNU stat -c %s reports a file size; BSD stat commonly uses -f %z, but that form is not tested here. Avoid assuming that a GNU long option works on every platform. BusyBox provides applets whose availability depends on build configuration. Prefer a documented common interface where it meets the task (for example wc -c), or isolate platform-specific commands behind a capability check. POSIX editions and implementation versions matter; do not label a command portable merely because it worked on GNU and BusyBox. The tests below use the installed GNU and BusyBox implementations, not macOS. The stat and wc examples require both implementations to complete successfully before the example is considered successful; availability alone does not demonstrate an option works.
Practical examples
Run each example as a separate script in a fresh noninteractive Bash 5.2 process and empty practice directory. Tests use C locale; do not enter expected output as code.
Check utility availability
for tool in stat wc; do if command -v "$tool" >/dev/null 2>&1; then printf '%s: available\n' "$tool" fidoneExpected stdout:
stat: availablewc: availableAvailability does not prove support for a particular flag.
Compare GNU and BusyBox size commands
printf 'abcde' > data.txt || exit 1stat -c %s data.txt || exit 1busybox stat -c %s data.txtExpected stdout:
55Both installed implementations accept this option. That is not evidence for BSD stat.
Prefer a common byte-counting interface
printf 'abcde' > data.txt || exit 1wc -c < data.txt || exit 1busybox wc -c < data.txtExpected stdout:
55Both tested utilities count bytes from standard input. BusyBox must be installed for the second command.
Common mistakes
Do not infer utility features from the Bash version or blindly replace sed -i flags. Test the actual operation and check status; avoid changing real input files.
Practice
On your machine identify the implementations of stat and wc. In a new directory create a five-byte ASCII file and compare the documented size command with wc -c. Record exact versions and whether each command succeeds; do not claim untested platform support.
Next: Argument parsing and CLI design