How to perform grep on curl within for loop?

后端 未结 2 1580
长发绾君心
长发绾君心 2021-01-26 04:02

I have created an array uisng the command IFS=\', \' read -r -a array <<< \"$(command)\"

The array has values:

abc001
abc002
abc003         


        
2条回答
  •  醉酒成梦
    2021-01-26 04:45

    #!/bin/bash
    
    for element in "${array[@]}"; do
      if curl -m1 -s "http://$element:8888"; then
        echo "'$element' connected" && break
      fi
    done
    

提交回复
热议问题