- 论坛徽章:
- 0
|
本帖最后由 WisdomFusion 于 2012-07-11 08:53 编辑
回复 7# waker
awk & sed 2/e里如是:
6.1.1 Append Next Line
The multiline Next (N) command creates a multiline pattern space by reading a new line of input and appending it to the contents of the pattern space. The original contents of pattern space and the new input line are separated by a newline. The embedded newline character can be matched in patterns by the escape sequence "\n". In a multiline pattern space, the metacharacter "^" matches the very first character of the pattern space, and not the character(s) following any embedded newline(s). Similarly, "$" matches only the final newline in the pattern space, and not any embedded newline(s). After the Next command is executed, control is then passed to subsequent commands in the script.
那么,- sed -e '/REGEX/{r filein' -e ';N}' fileout
复制代码 /REGEX/ 匹配后,进入{ }
先r把filein内容放入pattern space
再N把当前 /REGEX/ 匹配的行append到 multiline pattern space里?
另外,r命令用-e分隔,有没有别的办法解决2楼的错误?放一行上。
请教 |
|