zj@zj:~/Script/cushell/08.11.15$ cat sed.data
test1
1
11
test2
2
22
test3
3
33
test4
4
44
zj@zj:~/Script/cushell/08.11.15$ sed -n '/test/{:l;N;/test/{p;s/.*//};$!bl}' sedsed -n '/test/{p;:a;n;p;/test/q;b a}' sed.data
test1
1
11
test2
zj@zj:~/Script/cushell/08.11.15$ sed -n '/test/{n;:a;p;n;/test/q;b a}' sed.data
1
11
zj@zj:~/Script/cushell/08.11.15$ sed -n '/test/{:l;N;/test/{s/^\n//;p;s/.*//};$!bl}' sed.data
test1
1
11
test2
2
22
test3
3
33
test4
自己体会区别去把,累了,难得写了.
|