我有这样的文件(第一列的数字是行号)
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脚本。
使用sed
sed -n '/^32/,/^39/p' file
sed的另一种方法:
sed -n '32,39p' filename
sed -n '32,39p' input > output
请注意,这会忽略行号,只需打印32到39行。如果要匹配字符串,请使用Fredrik提出的解决方案。
我想你应该试试这个
sed '32,39!d' input > output