Last active
February 2, 2016 05:21
-
-
Save christianhujer/9c28c591794581832eda to your computer and use it in GitHub Desktop.
Highlights incoherence in a directory tree.
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
#!/bin/bash | |
startDir=$1 | |
wordToFind=$2 | |
for dir in $(find $startDir -type d) ; do | |
echo -n "$dir:" | |
for file in $(find $dir --depth 1 -name "*.rb") ; do | |
if grep $wordToFind $file >/dev/null ; then | |
echo -n "X" | |
else | |
echo -n "_" | |
fi | |
done | |
echo | |
done | grep -C 9999 X |
markburns
commented
Jan 31, 2016
#!/usr/bin/env ruby
require 'colorize'
def puts(v)
@buffer ||= ""
@buffer << v
end
Dir.glob(ARGV[0]).each do |f|
if File.directory?(f)
puts "\n#{f}"
else
if File.read(f)[ARGV[1]]
puts "X".red
else
puts "."
end
end
end
STDOUT.puts @buffer
result = Dir.glob(ARGV[0]).map do |f|
if File.directory?(f)
"\n#{f}"
else
if File.read(f)[ARGV[1]]
"\e[0;31;49mX\e[0m"
else
"."
end
end
end.join ""
puts result
puts(Dir.glob(ARGV[0]).map do |f|
File.directory?(f) ? "\n#{f} " : (File.read(f)[ARGV[1]] ? "\e[0;31;49mX\e[0m" : ".")
end.join(""))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment