Skip to main content
2 of 3
deleted 17 characters in body
user avatar
user avatar

You can try something like

#!/bin/bash 
cat file2.txt | while IFS=, read line; do

sed -i "/$(grep $line list1.txt)/d" file1.txt

done

Be aware that sed -i will make direct changes to file1.txt, but you can change the command to sed -i.ibk in order to save a backup copy of the original file.

For example

$cat file2.txt 
1.1.1.1
7.7.7.7

$cat file1.txt 
1.1.1.1,string1,comment1
7.7.7.7,string3,comment3
2.2.2.2,string2,comment2
88.88.88.88,string4,comment4
999.999,999,999,string5,comment5

output 
2.2.2.2,string2,comment2
88.88.88.88,string4,comment4
999.999,999,999,string5,comment5
user88036