I have got a list of public dns (in a file called dns.test).It looks like some of its elements do not resolve. I need to eliminate them. Here is the file:

```
199.255.137.34
103.112.162.165
103.133.222.202
82.146.26.2
94.236.218.254
185.81.41.81
103.209.52.250
119.160.80.164
8.8.8.8
8.8.4.4
151.80.222.79

```

note: there is no blanks, trailing or heading spaces.

I made a snippet to check them one by one and remove the faulty ones:

```
while IFS='\n' read -r LINE;do dig +short +timeout=1 serverfault.com @${LINE} &>/dev/null;[[ $? -eq 0 ]] && echo "${LINE} -> OK" || { echo "${LINE} -> NOK";sed -i "s/${LINE}//g" dns.test; };done< <(cat dns.test)

```

I shorten the timeout otherwise it's the hell slow!

but the sed part does not work; I base the sed part of the snippet on the following test:

```
LINE=199.255.137.34;sed -i "s/${LINE}//g" dns.test  #-> this works manually but not when included in the script.

```

thankx folks!!