bash - 使用 bash 读取文本文件中行的子集

标签 bash

我有一个文件

line a - this is line a
line b - this is line b
line c - this is line c
line d - this is line d
line e - this is line e

问题是:如何使用 bash 命令输出从“line b”到“line d”的行? 我的意思是,获得:

"line b - this is line b
 line c - this is line c
 line d - this is line d"

最佳答案

sed -n '/line b/,/line d/p' file

关于bash - 使用 bash 读取文本文件中行的子集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1083601/

相关文章:

linux - 通过 while 比较循环遍历数组

linux - 给定一个 IP 地址,在同一子网中查找接口(interface)

linux - 字符串替换模式匹配在 bash 脚本中不起作用

linux - 启动 Sublime Text 的快捷命令 "ed"

linux - 排除文件的grep数组参数

linux - 在 BASH 脚本中使用 'awk' 将列添加到 CSV 文件的末尾

从 R 脚本运行 bash 脚本

ZSH 和 Oh-My-Zsh 本地环境映射?

linux - 在一个目录中查找不在另一个目录中的文件

bash - 如何避免解压缩 "archives were successfully processed."输出