Storing values using if inside while loop BASH
问题 I am working with a new script that reads from a log file and then stores the ips which match one of the two patterns: Either its a failed attempt or its a failed attempt using ssh. My code runs good, but the problem is that when the while condition finishes, when I want to call the variable which stores all the IPs it only shows the last one. #!/bin/bash while IFS=";" read -r p || [ -n "$p" ] do first=$(echo $p | sed -E -e "s/[[:blank:]]+/;/g" | cut -d ";" -f 6) if [[ $first == "Failed" ]];