simple scripting question

I am new to scropting and I am just trying to work on a few simple things....
Using sh I want to do something similar to the follwoing run a simple command like a dig then I want it to get the server that it is authorotative and return it to me saying somehting like xx.xx is authorotative. I am not getting how to make it check the results and return a specific part to me how do I make it check the results it recieved and return a specific part of the results to me does this make sense? Is it possible. This is only an example of somethign I am trying to do I understand how to make it so that if a particualr event is true then do this but I dont understand how to make it check to see if that particualr even is present does this make sense let me know.

You can use 'grep' to look for some specific output and then perform any action based on those results. Recommend purchasing or borrowing an introductory shell scripting book. Check the FAQ section of this forum for recommendations.

I dont see how I could sue grep to search for a specific output when the output is going to be diffrent each time example in the case of a dig the authorative server is going to be different every time so I can't search for anythign specific. So I dont see how grep would work let me know

Pls post the question in detail,So we can give the answer.
But as per my thinking you want to search specific patern in a file,then you can directly type like this :

$grep (patern_name) filename