how do i make grep return only one match?

i have a variable that contains multiple matches.

RESULT = "Debra Jones Debra Jones Jonathon Taylor"

MATCH=`echo $RESULT |  grep -i -o -h -f ncm.txt`

MATCH contains  "Debra Jones Debra Jone" because ncm.txt is a list of names.

I need for grep to return only ONE match. How do I do this?

davysouthernboyAsked:
Who is Participating?
 
woolmilkporcCommented:
Which result would you liket o see?

The first one?

MATCH=$(echo $RESULT |  grep -i -o -h -f ncm.txt | head -1)

The last one?

MATCH=$(echo $RESULT |  grep -i -o -h -f  ncm.txt | tail -1)

Or did I understand you wrong? In this case, please explain!

wmp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.