I have two files:
File1:
ABC123
XYZ123
File2:
ABC123,APPLE
ABC123,BALL
XYZ123,BAT
ABC123,CAT
HJK456,MAT
I want to remove all the patterns in File2, which are there in File1. Meaning I want to removed ABC123 and XYZ123 from File2. For doing this I am running the below script.
while read -r line
do
sed -i "/$line/d" $File2
done<File1
With this script the File2 will have
HJK456,MAT
This script is serving my purpose, but I want to do this where File1 has 100 000 entries and File2 has 500 000 entries. I know the sed is slow here. Can anyone help me to get some command which will do this job and its faster.