How do you delete all lines that begin with “string” in unix sh?

前端 未结 4 1272
没有蜡笔的小新
没有蜡笔的小新 2020-12-13 19:33

How do you delete all lines in a file that begin with \"string\" in sh? I was thinking about using the sed command.

4条回答
  •  粉色の甜心
    2020-12-13 19:39

    You can use Vim in Ex mode:

    ex -sc g/^string/d -cx file
    
    1. g select all matching lines

    2. d delete

    3. x save and close

提交回复
热议问题