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

`rm $file` fails with `rm: cannot remove 'monthly': No such file or directory` and `rm: cannot remove 'report.csv'`.

BeginnerTroubleshootingTroubleshooting: quoting, expansion and tool-input bugs
Answer

Likely causes → file="monthly report.csv" was word-split into two arguments because it was not quoted. A name with * would be worse: it would expand to other files.

Diagnose → printf '[%s]\n' $file shows the split.

Fix → rm -- "$file".

Prevent → Quote every expansion; test scripts with filenames containing spaces, quotes and leading dashes.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

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