If you want that the presence of "server1.internet.com" should not cause "server1-h1.internet.com" to appear in the output file then perhaps this will help.
Code:
if [[ "$line2" =~ "${line%%.*}" ]] ; then
The =~ binary operator uses the right hand side as a pattern to be matched in the left hand side. You can manipulate the pattern to be matched using bash parameter expansions as in the example shown above.
You can also use grep style regular expression syntax such as ^ for start of line, $ for end of line and . for character in the pattern.
So,
Code:
if [[ "$line2" =~ ^"${line%%.*}" ]] ; then
will force the match to occur only at the start of $line2