public
Created

get unique lines from files

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/env ruby
 
my_files = Dir.chdir(ARGV[0]) { Dir.glob("./*").map{|x| File.expand_path(x) } }
 
def my_array_steamer(oldarr, newfile)
lines = (File.readlines(newfile)).map(&:strip)
oldarr | lines
end
 
my_arr = Array.new
my_files.each do |x|
my_arr = my_array_steamer(my_arr,x)
end
 
File.open('temp.txt', 'w') {|f| f.puts(my_arr) }

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.