0

Im trying to use the patterns in a file to grep another one but there's no output. I know they are there because I can see and use gedit "Find". Here's what I'm doing

grep -f scored.txt index.txt

And heres a sample of both files:

score.txt

11gs

1amw

1alw

1a8i

1a0q

index.txt

11gs,2.30,1999,5.82,Ki=1.5uM,11gs.pdf,(GTT-EAA)
1a0q,2.30,1999,7.57,Ki=27nM,1a0q.pdf,(HEP)
1a8i,1.78,1998,5.52,Ki=3.0uM,1a8i.pdf,(GLS)
1alw,2.03,1998,6.52,Ki=0.3uM,1alw.pdf,(ISA)
1amw,1.85,1998,4.54,Kd=29uM,1a4h.pdf,(ADP)

I'm edditing here because this example case WORKS. However, when I try with the full files I still don't get any output

Marcos Santana
  • 911
  • 5
  • 12
  • 21
  • What does _not_ work? For the given command, what is your incorrect output? – Inian Apr 04 '18 at 04:53
  • My incorrect output is nothing. It returns nothing. – Marcos Santana Apr 04 '18 at 04:53
  • If I put -v on my grep command it returns all lines from index.txt – Marcos Santana Apr 04 '18 at 04:54
  • note that this would search anywhere in the line, not just at start.. and `11gs` would match `211gsa` as well... as to the problem itself, we cannot help if we cannot test it.. you have files that do fail.. so try to keep deleting lines from either/both files until you can spot the issue – Sundeep Apr 04 '18 at 04:56
  • 2
    Using `grep -f scored.txt index.txt` returns the output as expected, does your file have DOS CRLF terminators? Can you post the contents of `cat -v scored.txt index.txt` – Inian Apr 04 '18 at 04:56
  • This command return a strange output. All lines in scored.txt were like this: 11gs^M. But index.txt lines were the same – Marcos Santana Apr 04 '18 at 04:58
  • 1
    @MarcosSantana: Remove `^M` from `scored.txt` by running `dos2unix scored.txt` – Inian Apr 04 '18 at 05:01
  • Now it works. I check special characters like you and Cyrus mentioned and ran dos2unix. Thanks guys! – Marcos Santana Apr 04 '18 at 05:02
  • see also: https://stackoverflow.com/questions/45772525/why-does-my-tool-output-overwrite-itself-and-how-do-i-fix-it – Sundeep Apr 04 '18 at 05:07

0 Answers0