ruby 去掉文件里重复的行
作者:
以前合并后台字典时,有重复的都是用vbs去,最近又看了一天的ruby,想起来写一下,没想到代码如此精简
old = File.open(ARGV[0]).collect
new = File.open(ARGV[1],"a+")
for i in 0..old.length-1
new.write(old.uniq[i])
end
##或简单两行也可以如qc.rb
old = File.open(ARGV[0]).collect
puts old.uniq
然后qc.rb dic.dic >new.dic
new = File.open(ARGV[1],"a+")
for i in 0..old.length-1
new.write(old.uniq[i])
end
##或简单两行也可以如qc.rb
old = File.open(ARGV[0]).collect
puts old.uniq
然后qc.rb dic.dic >new.dic