当前页面: 开发资料首页 → J2SE 专题 → 请教用什么命令:能去掉UNIX下某个目录(及其子目录)下所有*.htm文件内容中的“abcd”字符串
请教用什么命令:能去掉UNIX下某个目录(及其子目录)下所有*.htm文件内容中的“abcd”字符串
摘要: 请教用什么命令:能去掉UNIX下某个目录(及其子目录)下所有*.htm文件内容中的“abcd”字符串
如题:
请教用什么命令:能去掉UNIX下某个目录(及其子目录)下所有*.htm文件内容中的“abcd”字符串。
谢谢!
不知道,这辈子还没有摸过UNIX呢。。。
有谁知道吗?
没有这样的命令,除非你有兴趣写shell脚本,那样还不如用java写个程序来的快一点
在Unix下写一个shell然后grep一下
这个怎么问到JAVA版里来了?
用JAVA打开文件,替换之后再保存~~~~
╭═══════════════════╮
║ 免费的源码、工具网站,欢迎大家访问!║
║ http://www.j2soft.cn/ ║
╰═══════════════════╯
发错版啦,楼主
写个shell吧
#/bin/bash
for i in *.htm; do
sed -e 's/abcd//g' $i
done
没有这样的命令,除非你有兴趣写shell脚本,那样还不如用java写个程序来的快一点
............
无语中。。。。
jfjf
有语胜无语
import os
def test(path, ext):
for f_or_d in [path + os.sep + s for s in os.listdir(path)
if (os.path.splitext(s)[1] in ext or os.path.isdir(path + os.sep + s))]:
if os.path.isdir(f_or_d):
test(f_or_d, ext)
else:
print 'modify file:' + f_or_d
f = open(f_or_d, "r+")
data = f.read()
data = data.replace("abcd", "")
f.seek(0)
f.truncate()
f.write(data)
f.close()
if __name__ == "__main__":
test("d://DownLoads", ['.htm'])