linux - 从每个起点删除 N 行

标签 linux perl scripting

我如何删除从我看到的每个单词实例开始的 6 行?

最佳答案

我认为这个 sed 命令会做你想做的事:

sed '/bar/,+5d' input.txt

它删除包含文本 bar 的任何行以及以下五行。

如上运行以查看输出。当您知道它工作正常时,使用开关 --in-place=.backup 实际执行更改。

关于linux - 从每个起点删除 N 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3027529/

相关文章:

使用 Cygwin 安装 Perl CSV_XS 模块失败

perl - 如何在perl脚本中等待按键?

从 setuid root C 程序调用脚本 - 脚本不以 root 身份运行

batch-file - PsExec 和无效句柄

linux - 在 Bash 脚本中比较字符串时找不到命令错误 (stderr)

linux - SED 替换为斜线和单词

linux - 恢复 hibernate 分区

linux - 如何在 bash 中一个一个地读取 ls 命令列出的文件?

linux - 如何在终端中从 grep 中删除列

perl - 在 Perl 中, `use lib` 和 `lib->import` 有什么区别?