Delete strings based on patterns in another file

I have two files:

input.txt :

 Hi 1-12T2EDD 1-13D62L6Hello 1-15SDWAKWazzup Wow1-18Z3QWY 

filter.txt :

 1-15SDWAK 1-1VF3XHV 

I want to remove lines with the appropriate pattern from filter.txt in input.txt . In SQL understanding, I want to make a left outer join input.txt using filter.txt .

output.txt :

 Hi1-12T2EDD 1-13D62L6Hello Wow1-18Z3QWY 
+4
source share
1 answer

A simple grep will do the following:

 $ grep -Fvf filter input Hi 1-12T2EDD 1-13D62L6Hello Wow1-18Z3QWY 

Options:

  • -F for fixed strings since we don't need a regex
  • -v for backward matching
  • -F to specify a file containing string matching (reverse).
+5
source

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


All Articles