Read a file of hostnames and run `uptime` on each over SSH in parallel, max 10 at a time.

AdvancedHands-onBash scripting tasks
Answer
xargs -a hosts.txt -P 10 -I{} \
  ssh -o BatchMode=yes -o ConnectTimeout=5 {} 'echo "{}: $(uptime)"' 2>&1

Without xargs, using Bash job control:

while read -r host; do
  ssh -n -o BatchMode=yes -o ConnectTimeout=5 "$host" uptime | sed "s/^/$host: /" &
  while (( $(jobs -rp | wc -l) >= 10 )); do wait -n; done
done < hosts.txt
wait

Key trick → ssh -n (or BatchMode with xargs) stops ssh from swallowing the rest of stdin, which is why naive while read + ssh loops only process the first host.

All Real-World Interview questions Roadmap: Interview readiness

More on Bash scripting tasks