参考:http://blog.csdn.net/zcwfengbingdongguke/article/details/13951527 代码: #!/usr/bin/python import os import re #list files def listFiles(dirPath): fileList=[] for root,dirs,files in os.walk(dirPath): for fileObj in files: fileList.append(os.path.join
假设有文件test.txt,想把test.txt文件第三列含有的good替换为bye,并把替换后的文件保存为test_bye.txt,只需要如下命令. test.txt go go good go my my go good bye my good bye test_bye.txt go go bye go my my go good bye my bye bye awk -F " " '{if ($3==good) $3=bye}1' test.txt > test_bye.t