Created
September 26, 2013 06:24
-
-
Save perfectfoolish/6710485 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
require 'find' | |
puts "" | |
puts "-----------------------File Search-----------------------------------" | |
puts "" | |
print "Enter the search path : " | |
searchpath = gets | |
searchpath = searchpath.chomp | |
puts "" | |
print "Enter the search pattern : " | |
pattern = gets | |
pattern = pattern.chomp | |
puts"----------------------------------------------------------------------" | |
puts "Searching in " + searchpath + " for files matching pattern " + pattern | |
puts"----------------------------------------------------------------------" | |
puts "" | |
Find.find(searchpath) do |path| | |
if FileTest.directory?(path) | |
if File.basename(path)[0] == ?. | |
Find.prune # Don't look any further into this directory. | |
else | |
next | |
end | |
else | |
if File.fnmatch(pattern,File.basename(path)) | |
puts "Filename : " + File.basename(path) | |
s = sprintf("%o",File.stat(path).mode) | |
print "Permissions : " | |
puts s | |
print "Owning uid : " | |
puts File.stat(path).uid | |
print "Owning gid : " | |
puts File.stat(path).uid | |
print "Size (bytes) : " | |
puts File.stat(path).size | |
puts "---------------------------------------------------" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment