in reply to Re: Filtering lines from one file from another
in thread Filtering lines from one file from another

bellaire,
First, I believe your grep usage would need to be modified because as-is, the lines will be treated as regular expressions and not fixed strings. Second, I wonder how this would work if arbitrarily large files need to be supported. For instance, sort resolves this issue by using an on-disk divided and conquer strategy so assuming you have enough free filesystem, you can sort any size file. I just don't know how grep would do in this situation.

Cheers - L~R

  • Comment on Re^2: Filtering lines from one file from another

Replies are listed 'Best First'.
Re^3: Filtering lines from one file from another
by antonn (Initiate) on Feb 03, 2011 at 18:40 UTC
    I have tried with grep -xvf file2 file1 and seems to work
      True, or even further, grep -xvFf, to not only match the entire line, but to treat the "patterns" from file2 as fixed strings rather than regexes. L~R has a good point about large file size limitations, though. I can't really speak to that point.
      antonn,
      The reason it seems to work is due to your specific data set. The solution without modification is fragile. This is because grep assumes that the file contains regular expressions (called patterns) not fixed strings. It would be better to add the -F option as shown by bellaire to treat them as fixed strings.

      Cheers - L~R