Please post the contents of test.txt and mention what you need to do to get the final/required output along with the required output. This way you might get a better solution than the unnecessary pipeline.
mars IN A 202.27.17.78
sentosa IN A 202.27.17.100
www IN CNAME mars
majordomo IN CNAME mars
smtp2 IN CNAME sentosa
smtp3 IN CNAME venus.test.com.
Script suppose to grep for CNAME without the "." at the end and append them with .test.com. so that the above will become,
mars IN A 202.27.17.78
sentosa IN A 202.27.17.100
www IN CNAME mars.test.com.
majordomo IN CNAME mars.test.com.
smtp2 IN CNAME sentosa.test.com.
smtp3 IN CNAME venus.test.com.