From 3116da4d2ccbdc219e944dc535d8a8a42447f00f Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Wed, 11 Aug 2010 12:01:20 -0700 Subject: [PATCH] Add head_grep to grep only the first few lines --- head_grep.sh | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) create mode 100755 head_grep.sh 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 -- 1.6.6.rc1.39.g9a42