Delete lines based on line number

I have a file with ~200K lines, I need to delete 4K lines in it. There is no range.
I do have the line numbers of the lines which I want to be deleted.

I did tried using

> cat del.lines
sed '510d;12d;219d;......;3999d' file

> source del.lines
Word too long.

I even tried pasting the line in shell, it didn't allow, the number of characters in my file in the single line is - 16993.

Thanks for any help.

You can do something like this:

  1. Prepare a file with the numbers of the records to be deleted, one per line:

lines_to_delete

510
12
219
3999
  1. Run the following script:
awk 'NR == FNR {
  ltd[$1]; next
  }
FNR in ltd { next }
1' lines_to_delete infile  

infile is your data file.

awk 'NR==FNR{n[$1];next}!(FNR in n)' lines_nos_to_be_deleted_in_a_file  input_file > output

worked, Thanks.