File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -557,13 +557,7 @@ sed -i '.tmp' 's/But/but/g' test-2.txt
557557
558558这个看起来有点熟悉对不对?如果你比较之前的语句,会发现多了一个` g ` 。在这里,如果不加` g ` 则只会替换每行的第一个` But ` ,而加` g ` 则会替换所有的` But ` 。如果你只是要替换某一个位置的` But ` ,比如第三个,则可以` sed -i '.tmp' 's/But/but/3' test-2.txt ` 。
559559
560-
561-
562-
563-
564-
565-
566-
560+ 更多的` sed ` 用法,可以参考:http://www.grymoire.com/Unix/Sed.html#uh-1 。
567561
568562<h4 >9. 输出输入</h4 >
569563<h4 >10. 函数</h4 >
@@ -576,5 +570,5 @@ sed -i '.tmp' 's/But/but/g' test-2.txt
576570<li ><a href =" http://www.tutorialspoint.com/unix/index.htm " >3. Unix Tutorial Point</a ></li >
577571<li ><a href =" http://linux.about.com/ " >4. about.com</a ></li >
578572<li ><a href =" http://www.grymoire.com/Unix/Sed.html#uh-1 " >5. Sed - An Introduction and Tutorial by Bruce Barnett</a ></li >
579- <li ><a href =" http://www.thegeekstuff.com/2009/09/unix-sed-tutorial-replace-text-inside-a-file-using-substitute-command/ " >The Geek Stuff</a ></li >
573+ <li ><a href =" http://www.thegeekstuff.com/2009/09/unix-sed-tutorial-replace-text-inside-a-file-using-substitute-command/ " >6. The Geek Stuff</a ></li >
580574</ul >
You can’t perform that action at this time.
0 commit comments