Skip to content

Instantly share code, notes, and snippets.

@int64ago
Last active August 29, 2015 14:11
Show Gist options
  • Save int64ago/094ced8c26a7936110ba to your computer and use it in GitHub Desktop.
Save int64ago/094ced8c26a7936110ba to your computer and use it in GitHub Desktop.
Find the substring from all files of current directory recursively
#!/bin/bash
path='.'
keyword=$1
function deep(){
for file in `ls $1` ; do
if test -d $1"/"$file ; then
deep $1"/"$file
else
cat $1"/"$file | grep $keyword > /dev/null
if [ "$?" == "0" ] ; then
echo ">>>>>"$1"/"$file
cat $1"/"$file | grep $keyword
fi
fi
done
}
deep $path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment