On Sun, 15 Jul 2007, BartlebyScrivener wrote:
On Jul 15, 3:00 pm, William Pursell <[EMAIL PROTECTED]> wrote:
You might consider the -C (or -B or -A) options to grep.
Yes, I've played with these, too. The problem in large text files
with wrapped paragraphs, each "line" can be quite long, so even -C1
gives a big block before and after. But it's better than nothing.
Thank you,
rd
probably the easiest thing to do is write up a little wrapper for grep
like so:
#!/bin/sh
if [ -z $1 ] ; then
echo "please enter file type"
exit 1
fi
if [ -z $2 ] ; then
echo "please enter search pattern"
exit 1
fi
for FILE in `find . -type f -name "*$1" -exec grep -il $2 {} \; ` ; do
echo " " ; echo "**" ; echo $FILE
grep --color -i $2 $FILE
done
save that to your ~/bin/ directory , chmod +x ~/bin/scriptname then cd to
what ever directory you want to search and for example, to search files
ending with txt and have pattern in them:
scriptname txt pattern
-+-
8 out of 10 Owners who Expressed a Preference said Their Cats Preferred Techno.
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]