如何在UNIX中将两个行号之间的文本打印到新文件中 [英] How to print text between two line numbers into a new file in UNIX

查看:85
本文介绍了如何在UNIX中将两个行号之间的文本打印到新文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像这样的文件(第一列中的数字是行号)

I have a file like this (numbers on first column is line number)

30.<unit id=20>
31....
32.</unit>
33.<unit id=40?
34....
35.</unit>
36<unit id=20>
37...
38.</unit>
39.<unit id=40?
40....
41</unit>

我想在两个行号(例如32和39)之间打印行.如何在Unix中完成此操作?
我是unix的新手. 注意:我不要perl脚本.

I want to print lines between two line numbers, say 32 and 39. How can I accomplish this in Unix?
I'm new to unix. Note: I don't want perl scripts please.

推荐答案

使用sed

sed -n '/^32/,/^39/p' file

这篇关于如何在UNIX中将两个行号之间的文本打印到新文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆