A script that reads `hosts.txt` and SSHes to each host only processes the first host, with no error.
IntermediateTroubleshootingTroubleshooting: quoting, expansion and tool-input bugs
Answer
Likely causes → ssh inherits the loop's stdin and reads the rest of hosts.txt as input for the remote command, so the loop ends after one iteration. docker exec -i, kubectl exec -i and mysql do the same.
Diagnose → Add echo "next: $host" at the top of the loop; it prints once.
Fix → ssh -n "$host" ... (stdin from /dev/null), ssh ... < /dev/null, or read the list on another descriptor: while read -r host <&3; do ...; done 3< hosts.txt.
Prevent → Always use ssh -n (or -o BatchMode=yes plus < /dev/null) inside read loops.
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