Last active
January 10, 2018 01:50
-
-
Save gbpereira/a049607baa3dbc0885e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
if ARGV.any? | |
filename = ARGV.shift | |
content = File.open(filename) | |
sorted_filename = ARGV.shift || "sorted-#{filename}" | |
sorted_file = File.new(sorted_filename, 'w') | |
sorted_file.write(content.sort.join('')) | |
puts "Done. #{sorted_filename} generated." | |
else | |
puts 'Wrong number of params. '\ | |
'Usage: ./file-sorter source destination(optional)' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment