文件内容:
abc def
ijk lmn
opq rst
uvw xyz
sed '/\(.*\)def/{N;s/\(.*\)def\n\(.*\)lmn/Replaced\nSuccess/}' file
输出:
Replaced
Success
opq rst
uvw xyz
按预期工作。
但是对于文件内容:
2013-09-17-01:02:43 User: ID_123456@some.tld
2013-09-17-01:02:43 Last login time: Never
hello
how are you
catch up tmrw
sed '/\(.*\)tld/{N;s/\(.*\)tld\n\(.*\)Never/Replaced\nSuccess/}' file
这行不通。
预期输出:
Replaced
Success
hello
how are you
catch up tmrw
问题出在哪里?