- 论坛徽章:
- 0
|
呵呵!
问题又来了哦!
Let me think about it !
Mr. 2007 ,你将源文件修改为 :
# more 2.txt
I am a student , I like UNIX , I aways read the User and Operation
Documents, I know it is very important for me .
But , I do not like the User and Operation Documents . Since it is so
difficult for reading and understanding . *** User
and Operation Documents ***
Last Sunday , one of my friend told me that the User and
Operation
Documents
will upgraded to the Version 3.1 .
那么这道题目的目的应该是挑战一下,大家对于NEXT概念的理解了。
当通过NEXT将下一个行text读入自己的sed模式空间后,sed 无法发现在第二个
行中的匹配/User/ .
首先, sed 会逐行读取text , 但是当他发现匹配的模式后(/User/ /Operation/) , 会进入
多行的模式空间。
然后, sed 读入第二行,对其进行替换的工作。
但是, 这个时候,我们位于句尾的 User 是无法被匹配上的哦。
例如, 当你将*** User and Operation Documents *** 放在文章的最后,就可以替换了阿!
所以,我这边有一个简单的解决这个问题的答案哦!
就是:
# more 2.txt
I am a student , I like UNIX , I aways read the User and Operation
Documents, I know it is very important for me .
But , I do not like the User and Operation Documents . Since it is so
difficult for reading and understanding . *** User
and Operation Documents ***
Last Sunday , one of my friend told me that the User and
Operation
Documents
will upgraded to the Version 3.1 .
# sed 's/User and Operation Documents/Instruction Documents/g' 2.txt | sed -f sedscrip
I am a student , I like UNIX , I aways read the Instruction Documents, I know it is very important for me .
But , I do not like the Instruction Documents . Since it is so
difficult for reading and understanding . *** Instruction Documents ***
Last Sunday , one of my friend told me that the Instruction Documents
will upgraded to the Version 3.1 .
还是我的那个旧有的sedscript 。
不知道,我的分析,大家认可吗?
[ 本帖最后由 stephen412 于 2006-8-23 14:33 编辑 ] |
|