Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
sed 可以在与 match 匹配后删除一些行数
sed -e /regexp/,+<number_of_lines>
但是除了这第 10 行之外,如何删除
更新
好吧,这不是确切的问题。
匹配后需要删除第二、三、四、六行并匹配自身
如果你有GNU sed,你可以在比赛之后(包括)sed '/regexp/,+10d' file删除 10 行。您可以删除比赛之后(包括)第 4 行加上第 10 行。sed '/regexp/,+4d;10d' file
GNU sed
sed '/regexp/,+10d' file
sed '/regexp/,+4d;10d' file