I have written a command that output a list of hostnames, e.g. : clab148node11clab148node12clab148node15clab148node16Now, I would like to remove those nodes that do not respond to ping. For now I have something like this :for node in $nodesdo         result=$(ping -c 1 $node; echo $?)doneNow how do I remove nodes that have the $result different than 0 ?
How to remove element from the list?
bash;shell;shell script
I'd prefer to build a new list and replace an old one with a new:nodes=127.0.0.1 1.2.3.4 1.2.3.4 nodes_out=for node in $nodesdo     ping -c 1 $node >/dev/null 2>&1 && nodes_out+=$nodedonenodes=$nodes_out