So I have a list of indexes in a file called indexes.txt. I want to read every index in that file and delete the corresponding line from another file called input.txt. So far I have this implementation that works:
while read -r index
do
sed -i "${index}d" $input.txt
done < "indexes.txt"
However, this implementation does not scale well at all. My index.txt file has 12500 lines and input.txt has about 300,000. I think deleting each line and saving the input.txt each time is what takes so much time (a couple seconds for each index). Is there a way to do this more efficiently?
Edit: Sorry, forgot to mention that the indexes in indexes.txt are unique, strictly decreasing integers.