如標題所示,我試圖只改變第一次出現的單詞。通過使用 sed的/ this/that /'文件。 txtsed's/this/that /' - 忽略g但仍然替換整個文件
雖然我沒有使用g選項,它取代了整個文件。如何解決這個問題。?
UPDATE:
$ cat file.txt
first line
this
this
this
this
$ sed -e '1s/this/that/;t' file.txt
first line
this // ------> I want to change only this "this" to "that" :)
this
this
this
你不能用我的回答給予了充分的SED的例子。我測試過它併爲我工作。 – zaf 2010-06-02 09:40:04