Linux remove lines from one file in another

In this article let’s discuss about Linux remove lines from one file in another. Let’s go through the following methods without any delay.

Method 1:

If the files are sorted:

comm -23 file1 file2

-23 suppresses the lines that are in both files, or only in file 2. 
If the files are not sorted, pipe them through sort first...

If you are facing any issues with the above approach then try the alternative that is given below. It may look similar by have a try!

Method 2 :

grep -v "pattern" file > temp && mv temp file

Hope the above solution works.

Realted Posts : Kube delete cronjob