egrep function ???

I have exported
LOGAME=/TESTXXX
O_M=/dev/vgibbs/lvxxx

I am trying to egrep the same along with bdf as

bdf |-egrep -w '$LOGNAME|${O_M}' *** ( I want to grep both pattern with variable )

However the same is giving "egrep: $ anchor not at end of pattern."

The above output works if I give bdf |-egrep -w 'TESTXXX|/dev/vgibbs/lvxxx'

I want the above funtionality *** to be called in script, but the same is not giving the desired output .
I am working on HP-UX system and using ksh shell.

I am on to this for long and I am stuck with this. I am waiting for your assistance so as to proceed with creation of my script. This to be made live
by tomorrow.

Thanks and Regds
Kamlesh.

Change the single quotes to double quotes - these are preventing the variable expansion.

Cheers
ZB

I have already tried that. It's not working. When I call the same in scripts it gives output as :-
+ egrep -w /dev/vgibbsmig/lvxxx|
+ bdf
egrep: Unknown err.

The script is as follows:-
check_org()
{
bdf |egrep -w "${O_FS}|${O_M}"
if [ $? -eq 0 ]
then
echo "Original file system mounted "
else
echo "Original NOT MOUNTED"
exit 1
fi
}