Fastest Way to Delete a Line from Large File in Python

前端 未结 9 611
轮回少年
轮回少年 2020-11-30 03:58

I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need

9条回答
  •  抹茶落季
    2020-11-30 04:56

    Update: solution using sed as requested by poster in comment.

    To delete for example the second line of file:

    sed '2d' input.txt
    

    Use the -i switch to edit in place. Warning: this is a destructive operation. Read the help for this command for information on how to make a backup automatically.

提交回复
热议问题