🔥 3-day streak
CompTIA Linux+ (XK0-006)19 / 123
Question 19 of 123

A DevOps engineer writes a Bash script that must process a list of hostnames from a file called servers.txt. For each host, it should attempt an SSH connection test and print 'UP' only if the connection succeeds. The current loop always prints 'UP' regardless of connectivity: while read host; do ssh -o ConnectTimeout=5 "$host" exit echo "$host UP" done < servers.txt Which modification correctly prints 'UP' only when the SSH command succeeds?

Reviewed for accuracy · Report an issueNext question