From: Colin Patrick McCabe Date: Wed, 11 Aug 2010 19:01:20 +0000 (-0700) Subject: Add head_grep to grep only the first few lines X-Git-Url: http://club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3116da4d2ccbdc219e944dc535d8a8a42447f00f;p=cmccabe-bin Add head_grep to grep only the first few lines --- diff --git a/head_grep.sh b/head_grep.sh new file mode 100755 index 0000000..602c5b2 --- /dev/null +++ b/head_grep.sh @@ -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