Remove multiple lines from a text file

Hi

I have a text file named main.txt with 10,000 lines. I have another file with a list of line numbers (around 1000) of the lines to be deleted from main.txt file.

I tried with sed but it removes only a range of line numbers.

Thanks for any help!!

awk 'NR == FNR {a[$0]; next}
  {if(! (FNR in a)) {print}}' list.txt main.txt
1 Like