Samuel Williams Thursday, 17 September 2009

This script will scan for a specific mask on directories and print out the result:

#!/usr/bin/env ruby
 
require 'find'
require 'etc'
 
# http://permissions-calculator.org/
MASK = 0002
 
Find.find(ARGV[0] || "./") do |path|
	if FileTest.directory?(path)
		s = File::Stat.new(path)
		if (s.mode & MASK) != 0
			puts "#{s.mode.to_s(8)} #{Etc.getpwuid(s.uid).name} #{Etc.getgrgid(s.gid).name}: #{path}"
		end
	end
end

Comments

Leave a comment

Please note, comments must be formatted using Markdown. Links can be enclosed in angle brackets, e.g. <www.codeotaku.com>.