findinfiles3 bash script

#!/bin/bash
echo "$0: Finds where a string is in current dir & subdir files matching *wildcards*.ext . "
echo "Usage: findinfiles3 \"string\" \"*files\" <grep options 1,2,3. ex: -i>"
echo "----------------------------------------------------------------"
if [ "$1" = "" ]
then
  echo "You must supply a string to find."
  exit 1
else
  echo "Finding '$1' in '$2'..."
  echo "-------------------"
  find . -type f -iname "$2" -exec grep $3 $4 $5 --color -l -s "$1" {} \; -exec grep $3 $4 $5 --color -n -s "$1" {} \; -exec echo " " \;

fi


Example run: ~/bin/findinfiles3  “some phrase”   “*”   -i

 

One thought on “findinfiles3 bash script

Leave a Reply

Your email address will not be published. Required fields are marked *