【发布时间】:2020-05-03 08:44:03
【问题描述】:
我想用 sed 仅打印特定行的匹配项;
sed '1,4 /regextomatch/p':
sed:-e 表达式#1,字符 5:未知命令:`/'
什么是打印命令?
【问题讨论】:
我想用 sed 仅打印特定行的匹配项;
sed '1,4 /regextomatch/p':
sed:-e 表达式#1,字符 5:未知命令:`/'
什么是打印命令?
【问题讨论】:
我建议:
sed -n '1,4{/regextomatch/p}' file
【讨论】:
你可以使用退出命令:
sed -n '/regex/p;4q' file
【讨论】:
我宁愿这样做:
head -n 4 filename | grep regextomatch
【讨论】: