Removing lines from one list from another list.

Hello,

I was wondering if there was an easy way to take lines from a single-column list, and remove them from a second single-column list. For example, I want to remove the contents of list 1 from list 2. How would I do this?

Contents of list 1:

server1a
server2b
server3c
server4a
server5qb
server6ocd

Contents of list 2"

server1a
server2b
server3c
server4a
server5qb
server6ocd
server7dgw
server8sg
server9be
server10zt
server11w
server12t
server13f

Hi

Assuming your list1 is in file1, list2 in file2

grep -v -f file1 file2

Guru.

1 Like

Thank you. I didn't know it was that simple.

---------- Post updated at 01:25 PM ---------- Previous update was at 12:18 PM ----------

Also the comm command:

Print all lines that appear in file2 but not in file1 (in other words, print column 2):

 comm -13 file1 file2