Skip to content
Advertisement

How to remove the lines which appear on file 1 from another file 2 KEEPING empty lines?

I know that in other questions you solve the first part of “How to remove the lines which appear on file 1 from another file 2” with: comm -23 file1 file2 and grep -Fvxf file1 file2

But in my case I have empty lines separating data sets that I need to keep, for example:

File 1:

JavaScript

File 2

JavaScript

what I want as a result:

JavaScript

The solution can be in bash or csh.

Thanks

Advertisement

Answer

With awk please try following once.

JavaScript

Explanation: Adding detailed explanation for above code.

JavaScript
Advertisement