Filter file with another file in bash

i We have a file with numbers, for example:

$cat file 31038467 32048169 33058564 34088662 35093964 31018168 31138061 31208369 31538163 31798862 

and others for example using

 $cat file2 31208369 33058564 34088662 31538163 31038467 

Then I need another file with lines that are in the first file, but not in the second

 cat $output 35093964 31018168 31138061 31798862 32048169 

My real file has 12'000.0000 lines.

Then how can I do this?

+4
source share
1 answer

Is an

 grep -f file2 -v -F -x file1 

enough?

NOTE 1. Please indicate in the question if the actual question is what you need for it to be time / memory optimized.

NOTE 2: Get rid of empty lines in file2.

+9
source

Source: https://habr.com/ru/post/1495200/


All Articles