Add head_grep to grep only the first few lines
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 11 Aug 2010 19:01:20 +0000 (12:01 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 11 Aug 2010 19:01:20 +0000 (12:01 -0700)
head_grep.sh [new file with mode: 0755]

diff --git a/head_grep.sh b/head_grep.sh
new file mode 100755 (executable)
index 0000000..602c5b2
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+#
+# Grep the first few lines of a file.
+# Print out any matches if they are found, along with the file name.
+#
+# Colin McCabe
+#
+
+find -type f | while read F; do
+  if head -n 50 $F | grep -q ${@}; then
+    echo -n "${F}: "
+    grep ${@} $F
+  fi
+done