Grep fixed string is not grepping exact string, string end with extra character '-' is also coming

Viewed 1121

There is an option in grep to search the exact string "-F"

-F, --fixed-strings

Its working perfectly fine if there are two words where one is the word to be searched and another is appended with alphaumeric character. However, if the other word contains some special character like '-' then grep -F or grep -w is not matching correct result.

grep -w "hello" test1
hello
hello-

cat test1 
hello
hello-
hellotest

ideally only first line should have come in result.

1 Answers
Related