sed-shell 文件 我想取出第二行到第五行
- a
- b
- c
- d
- e
- f
- g
nl sed-shell | sed -n '2,5p'
# -n 安静模式 只有经过处理的行才会被列出来
# -p 打印,将某个选择的数据印出
执行结果
2 b
3 c
4 d
5 e
取不连续的行 比如 1,2,5,6行
nl sed-shel | sed -n '1p;2p;5p;6p'
取连续和不连续的都有 比如 1,2,3,4 和 6
nl sed-shel | sed -n '1,4p;6p'