Last active
December 16, 2015 01:09
-
-
Save lyuehh/5353023 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
path = ENV['PATH'].split(':') | |
all = [] | |
path.each do |p| | |
all.push(Dir.entries(p)) | |
end | |
puts all.flatten.select{ |a| a != '.' && a != '..' } |
puts ENV['PATH'].split(':').inject([]){|a,b| a.push(Dir.entries(b))}.flatten.select{ |a| a != '.' && a != '..' }.sort
恩,其实可以写成一行的
System getEnvironmentVariable("PATH") split(":") reduce(a,b,a push(Directory with(b) items reduce(a,b,a push(b name),list())), list()) flatten select(a, a != "." and a != "..") sort
io语言版本...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
排序一下比较好...