Skip to content

Instantly share code, notes, and snippets.

@davidoram
Created December 20, 2012 18:21
Show Gist options
  • Select an option

  • Save davidoram/4347454 to your computer and use it in GitHub Desktop.

Select an option

Save davidoram/4347454 to your computer and use it in GitHub Desktop.
Output a list of the unique file extensions in the current directory and all subdirectories, lowercased and sorted
#!/bin/ruby
# Output a list of the unique file extensions in this directory and all subdirectories
# lowercased and sorted
extensions = {}
Dir.glob('**/*') do |f|
ext = File.extname(f).downcase
extensions[ext] = ext if ext
end
puts extensions.keys.sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment