Interview Prep/Shell Scripting/Troubleshooting: quoting, expansion and tool-input bugs

`gzip /var/log/app/*.log` fails with `bash: /usr/bin/gzip: Argument list too long`

IntermediateTroubleshootingTroubleshooting: quoting, expansion and tool-input bugs
Answer

Likely causes → The glob expanded to so many filenames that the arguments exceed the kernel's ARG_MAX limit for execve().

Diagnose →

getconf ARG_MAX
find /var/log/app -maxdepth 1 -name '*.log' | wc -l

Fix → Let find batch the arguments:

find /var/log/app -maxdepth 1 -name '*.log' -exec gzip -- {} +

Prevent → Use find -exec {} + or xargs -0 for bulk operations; fix the retention that let 300,000 files accumulate.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Troubleshooting: quoting, expansion and tool-input bugs