0
我使用SED与N选项三个字符串,他错过了最后一个字符串。 如果偶数行则一切正常sed多行跳跃行与N选项
示例文本:
this is the first line
this is the second line
this is the third line
sed 'N;s/^.*\(first.*\)\n\(second.*$\)/\1\2/;s/ //g'
我想
thisisthefirstline thisisthesecondline
thethirdline
,但我得到
thisisthefirstline thisisthesecondline
第三行
最后一行不处理, SED跳过此下标
s/ //g
四行没关系
this is the first line
this is the second line
this is the third line
this is the fourth line
thisisthefirstline**thisisthesecondline**
thisisthethirdline
thisisthefourthline
为奇数行的并不总是处理最后一排
一个简单的解决方案 - 使用管道
sed 'N;s/^.*\(first.*\)\n\(second.*$\)/\1\2/' | sed 's/ //g'
,但我会做没有管