4

So I am trying to use

grep -v -f A.txt  B.txt

to display lines NOT included in file A but present in file B. When I

grep -f A.txt B.txt

everything works fine I receive output with correct lines highlighted, but when I use

grep -v -f A.txt B.txt

nothing is outputted in spite of the fact that not all lines match patterns. Does anyone knows why? I am interested in seeing lines NOT present in file A.

Note: I am including just a sample of original file but it includes all troublesome lines.

file B.txt contents:

/lgi/tch/4337984048.html
/mnh/tch/4337954734.html
/fct/tch/4337745272.html
/brk/tch/4337711890.html
/mnh/tch/4337530587.html
/mnh/tch/4337480118.html
/mnh/tch/4337393833.html
/wch/tch/4337280071.html
/wch/tch/4337105236.html
/brk/tch/4337068170.html

file A.txt contents:
/mnh/tch/4337480118.html
/mnh/tch/4337393833.html
/wch/tch/4337280071.html
/wch/tch/4337105236.html
/brk/tch/4337068170.html
sgp667
  • 1,797
  • 2
  • 20
  • 38
  • 3
    My guess is that your `A.txt` contains a blank line (probably at the end). That will cause the behavior you are seeing. – Sean Bright Feb 18 '14 at 20:13
  • see if your `bin` dir has `fgrep`, then use then use `fgrep -v -f ...`. OR, per my linux man page, `grep -F -v -f ...` should work. Good luck. – shellter Feb 18 '14 at 20:13
  • 1
    try comm http://stackoverflow.com/questions/14473090/find-lines-from-a-file-which-are-not-present-in-another-file – ACEnglish Feb 18 '14 at 20:15
  • Wow actually all of you gave me an answer that works. Thank you everyone. – sgp667 Feb 19 '14 at 18:49

0 Answers0