I use this command
JavaScript
x
while read line || [ -n "$line" ]; do grep -v "$line" target.txt > tmp; mv tmp target.txt; done < removefrom.txt
to remove lines from (target.txt) that match string in (removefrom.txt)
This is (target.txt)
JavaScript
e
1
k
2
a
This is (removefrom.txt)
JavaScript
d
e
c
a
k
b
e
a
This is the result should look like:
JavaScript
1
2
But sometimes the resule is like:
JavaScript
e
1
2
or
JavaScript
e
1
2
a
or
JavaScript
1
2
a
I ever try to use sed
, but the problem is still there, It didn’t remove lines properly.
Advertisement
Answer
grep -vf removefrom.txt target.txt