Using exact matching with grep in Shell program

sctccomm
sctccomm used Ask the Experts™
on
I writing a shell script, and in the script I would like to grep to perform an exact string match in another file.  Whenever I try to do this, the variable that I save the grep return in does not give the right results when checking that value.  Can someone please tell me if I am missing something.  Below is the portion of the code that I am working with.

serial="test1"
output=./script_report

check=`grep -m 1 -w "$serial" $output`

if [ "$check" != "" ]
then
........

When this function is run and "test1" does not exist within the file but a the string "test" does exist, the conditional returns true.  (should return false)

Thanks for the help.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2014
Top Expert 2015
Commented:
It is returning false when I try it

Author

Commented:
Okay, I fixed the problem, the grep work fine the way it is.  Just forgot to update the value of check after the first time.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial