学生问题:把一个文件test.log中所有包含oldboy的字符替换为good,同时把所有包含trainning的字符替换为luck。
要求一条命令实现(不能用循环,分号分隔命令等取巧法):

1)准备测试数据
[root@oldboy ~]# cat >test.log
here is oldboy trainning
I am oldboy.
welcome to oldboy trainning
[root@oldboy ~]# cat test.log
here is oldboy trainning
I am oldboy.
welcome to oldboy trainning
2)参考命令实现
法一:
[root@oldboy ~]# awk 'gsub("oldboy","good")gsub("trainning","luck")' test.log
here is good luck
I am good.
welcome to good luck
法二:
[root@oldboy ~]# sed -e 's#oldboy#good#;s#trainning#luck#' test.log
here is good luck
I am good.
welcome to good luck
法三:
[root@oldboy ~]# sed -e 's#oldboy#good#g' -e 's#trainning#luck#g' test.log
here is good luck
I am good.
welcome to good luck
特别感谢群内的朋友的支持。