惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
Vulnerabilities – Threatpost
Cloudbric
Cloudbric
G
GRAHAM CLULEY
S
Securelist
Schneier on Security
Schneier on Security
Help Net Security
Help Net Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Project Zero
Project Zero
Spread Privacy
Spread Privacy
P
Privacy International News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
T
Tailwind CSS Blog
博客园_首页
有赞技术团队
有赞技术团队
Simon Willison's Weblog
Simon Willison's Weblog
Stack Overflow Blog
Stack Overflow Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Latest news
Latest news
T
Tor Project blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Attack and Defense Labs
Attack and Defense Labs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
O
OpenAI News
J
Java Code Geeks
T
Tenable Blog
K
Kaspersky official blog
AWS News Blog
AWS News Blog
S
Security @ Cisco Blogs
The GitHub Blog
The GitHub Blog
T
Threatpost
月光博客
月光博客
H
Heimdal Security Blog
Security Latest
Security Latest
The Hacker News
The Hacker News
Y
Y Combinator Blog
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
C
Cisco Blogs
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
C
CERT Recently Published Vulnerability Notes
D
Docker
Google Online Security Blog
Google Online Security Blog
D
DataBreaches.Net
V
Visual Studio Blog
H
Help Net Security

博客园 - 乱草

仓央嘉措:如果爱是一场修行 重庆旅游 nothing qq签名 Linux也玩远程桌面(VNC) 五一海峡车展--汽车篇 五一福州海峡车展-美眉篇 ipad2 在购一台? 一月份在上海的几张照片 吉他英雄老爹 亲爱的宝宝 the daily 发布了 MSN中文网公布了"2010年度十大MSN经典签名" 色彩的魔力(转贴) 9月杭州 9月在上海的几张照片 最近被一个socket占用搞的头疼,记录一下netstat用法 nothing pl/sql 注册码
历遍目录,读取文件,然后将文件中的固定行替换掉
乱草 · 2011-11-29 · via 博客园 - 乱草

应该有很多方法可以更加简单,只是太久没有写程序了,赶鸭子上架了 

require 'iconv'

def myreplay(filename,tt)

    ##建立另外一个目录,将文件产生到新的目录中

    file=File.open('D://bak/tmp2/' + tt + '/' + filename,'w')

   i=0

   message=''

   File.open('D://bak/tmp/' + tt + '/' + filename).each do |f|

       message=f

           if(f=~/<ErrorFieldCount>0<\/ErrorFieldCount>/)

           (

                 file.print '<ErrorFieldCount>1</ErrorFieldCount>'

file.print "\n"

           )

       else

           (

            file.puts message

           )

       end

   end

end

def indirp(dirname)

dirp2 =Dir.open("D://bak/tmp/" + dirname)

 for m in dirp2

 case m   

                  when /^\./, /~$/, /\.o/,/.rb/,/.dat/ 

                  else  

 ##开始调用替换函数

#myreplay(m,dirname)

puts dirname 

puts m

myreplay(m,dirname)

                  end   

 end

end

dirp = Dir.open("d://bak/tmp")   

for f in dirp   

  case f   

  when /^\./, /~$/, /\.o/,/.rb/,/.dat/ 

  else  

 ##进入这个目录中

 indirp(f)

  end   

end   

dirp.close