document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. =begin
  2. input: ruby process.rb dir filename
  3. =end
  4.  
  5. def get_postfix (el)
  6.   match = el.match(/\\.(\\d{1,2})$/)
  7.   if match then match[1].to_i else 0 end
  8. end
  9.  
  10. if $*.length != 2
  11.   puts "Usage: ruby process.rb dir file"
  12.   exit
  13. end
  14.  
  15. dirname = $*[0]
  16. if ! File.directory? dirname
  17.   puts "`#{dirname}` is not a directory"
  18.   exit
  19. end
  20.  
  21. filename = $*[1]
  22.  
  23. entries = Dir.entries(".").select {|el| File.file? el and el.include? "access.log"}
  24. entries.sort! {|a, b|  get_postfix(a) <=> get_postfix(b) }
  25.  
  26. `echo -n > #{filename}`
  27. entries.each {|file|
  28.   `cat #{file} >> #{filename}`
  29.   puts file
  30. }
  31. puts "Done"
');