to select the names of the connect_string.

We could assume that on the line where we put the connect-string, we don't have '('-characters.
So we can have something like this

for fname in $( grep -v "(" tnsnames.ora | awk '{ print $1 }' )
do
tnsping $fname
.. continue with whatever you want to do.
done

Maybe you can use the output of the tnsping command to determine the hostname or IP-address of the connect-string you are testing. ( I would like to try, but don't have an oracle-system here )

Hope this helps
Gert