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