while read line; do ip="$(grep -oE '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}' <<< "$line")" echo "$ip" done < "abd"