Skip to content

Instantly share code, notes, and snippets.

@kardeiz
Created October 15, 2012 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kardeiz/3893099 to your computer and use it in GitHub Desktop.
Save kardeiz/3893099 to your computer and use it in GitHub Desktop.
get unique lines from files
#!/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) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment