0

File1:

Btr_0449a   447
Btr_0449    447

Desired output:

Btr_0449    447

I want grep to find 'Btr_0449', not 'Btr_0449a'. Seems I'm doing something wrong since:

grep -F "Btr_0449"

Btr_0449a   447
Btr_0449    447
biotech
  • 697
  • 1
  • 7
  • 17

2 Answers2

3

This should do it:

grep -Fw "Btr_0449"

From the grep manpage:

"-w Select only those lines containing matches that form whole words. "

ci_
  • 8,594
  • 10
  • 39
  • 63
1

If you insist to use '-F' flag, then adding a space after your string will do.

grep -F "Btr_0449 "

For the future, you will get much better results if you'll use regex patterns, so for the above query, you could do:

grep -e "Btr_0449\s"

...which will match your string followed by any whitespace character (space, tab, new line, carriage return...)