I need to output all lines in file1.txt
, except those that are found in file2.txt
, by matching the entirely lines.
E.g., file1.txt
:
Cats eat fish.
Mice eat cheese.
Eagles can fly.
Mountains are tall.
E.g., file2.txt
:
Cats eat fish.
Birds can fly.
Trees are tall.
E.g., output:
Mice eat cheese.
Eagles fly.
Mountains are tall.
I have used the following command:
grep -v -x -f file1.txt file2.txt
This appears to work, however, when the files are of certain lengths, it often reports grep: memory exhausted
, so I need an alternative that will not create this memory problem.
- The order of the lines is important, so they should not be sorted.
- Any tool typically found within a default Linux install will be acceptable.
How can I output the lines of file1.txt
, except those found in file2.txt
, without encountering a memory problem?