awk question (or sed, if that's better to use)

Hi all,

I'm pretty new to Unix (Sun) scripting, and wanted to try doing what many would probably believe is pretty easy. I tried searching the forums and only found bits and pieces of things I wanted to do below, but after many tries had a very hard time piecing it together.

Would anyone know how to:
a> Search the contents of "ifconfig -a" for either e1000 "or" igb0 and return only that "expression" (but not the whole word...ie: "e1000 instead of e1000g0" or "igb0 instead of igb0:1" )?

b&c> (I basically wanted to assign that 1-word result to $available_port) ...also needed, if neither "or" both are found, can $available_port = ERROR ?

extra info/clarification> There may be multiple times e1000 is found and that's okay. But if both e1000 "and" igb0 are found, that should instead assign ERROR to $available_port. Likewise, ERROR should be assigned if neither are found.

Thanks so much for your help,
CG

available_port=`ifconfig -a | awk -vRS="\x00" '$0~/e1000/ && $0~/igb0/{print "ERROR";next} /e1000/{print "e1000";next} /igb0/{print "igb0";next} {print "ERROR"}'`

I know.. It's ugly.