Wednesday, November 7, 2007

a small script for searching in subversion repositories..

If you are using subversion for versioncontrol, you might have sometimes the need to search for a string in all files.. here is a small script for doing this without checking the whole repository out.
This script needs only 1 argument: the string to search for.
PLEASE NOTE! change first and second line to match your own Repository.

REPO="svn"
BASEURL="http://svn.collab.net/repos/"
SEARCH=$1
svn ls -R "${BASEURL}${REPO}/trunk/" | while read file;
do
  result=`expr match "$file" '.*/$' | cat`
if [ $result == 0 ]; then
result=`svn cat "${BASEURL}${REPO}/trunk/$file" | grep $SEARCH | cat`
if [ -n "$result" ]; then
echo "${BASEURL}${REPO}/trunk/$file"
fi
fi
done

1 comment:

Unknown said...

How To Run This Script ???