Skip to content

Instantly share code, notes, and snippets.

@patrickt
Created May 21, 2010 18:18
Show Gist options
  • Save patrickt/409203 to your computer and use it in GitHub Desktop.
Save patrickt/409203 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
if ARGV.size < 1
puts "#{$0} folder1 [folder2 [folder3 ...]]"
exit 1
end
ARGV.each do |folder|
`find #{folder} -name '*.txt'`.each do |f|
file = f.chomp
content = `grep critical #{file}`
open(file, "w") { |io| io.print content }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment