A `while read` loop silently skips the last line of a config file.
BeginnerTroubleshootingTroubleshooting: quoting, expansion and tool-input bugs
Answer
Likely causes → The file does not end with a newline. read returns non-zero at EOF even though it read data into the variable, so the loop body is skipped for the final line.
Diagnose → tail -c1 file | od -c shows no \n at the end.
Fix →
while IFS= read -r line || [[ -n $line ]]; do
...
done < file
Prevent → Configure editors to add a final newline; use the || [[ -n $line ]] idiom in every read loop.
More on Troubleshooting: quoting, expansion and tool-input bugs
`bash: [: too many arguments`Beginner`bash: [: =: unary operator expected`BeginnerA disk check fails with `[: 93%: integer expression expected`Beginner`rm $file` fails with `rm: cannot remove 'monthly': No such file or directory` and `rm: cannot remove 'report.csv'`.BeginnerA cleanup script logs `cp: cannot stat '/var/log/app/*.log': No such file or directory` on quiet days.Beginner`echo "start" > $logfile` fails with `bash: $logfile: ambiguous redirect`Intermediate