常見例句$ awk '{ sub(/test/, "mytest");print }' testfile $ awk '{ sub(/test/, "mytest");$1}; print }' testfile 第一個例子在整個記錄中匹配,替換衹發(fā)生在第一次匹配發(fā)生的時候。$ awk '{ gsub(/test/, "mytest");print }' testfile $ awk '{ gsub(/test/, "mytest"), $1 }; print }' testfile[/pre]第一個例子在整個文檔中匹配test,匹配的都被替換成mytest。 返回 testfile