Skip to content

Instantly share code, notes, and snippets.

@christianhujer
Last active February 2, 2016 05:21
Show Gist options
  • Save christianhujer/9c28c591794581832eda to your computer and use it in GitHub Desktop.
Save christianhujer/9c28c591794581832eda to your computer and use it in GitHub Desktop.
Highlights incoherence in a directory tree.
#!/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
Copy link

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

@markburns
Copy link

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