How to delete from a text file, all lines that contain a specific string?

后端 未结 18 2392
生来不讨喜
生来不讨喜 2020-11-22 02:06

How would I use sed to delete all lines in a text file that contain a specific string?

18条回答
  •  一整个雨季
    2020-11-22 02:52

    You can also delete a range of lines in a file. For example to delete stored procedures in a SQL file.

    sed '/CREATE PROCEDURE.*/,/END ;/d' sqllines.sql

    This will remove all lines between CREATE PROCEDURE and END ;.

    I have cleaned up many sql files withe this sed command.

提交回复
热议问题