开发者

How to search the file contents in multiple subversion repositories?

开发者 https://www.devze.com 2022-12-22 17:56 出处:网络
I\'ve got multiple SVN repositories of different projects which I would like to search for the same search term / regex, but without checking out or updating e开发者_Python百科ach project and doing th

I've got multiple SVN repositories of different projects which I would like to search for the same search term / regex, but without checking out or updating e开发者_Python百科ach project and doing the search manually on each of them.

I'd like to know if it is possible to search the file contents in multiple SVN repositories for some search term (or regex).


Here is a script:

if [[ $# < 2 ]]; then
    echo "Usage: $0 REGEX TARGET..."
    echo "where REGEX is a regular expression for grep"
    echo "and TARGET... is a list of SVN repositories"
    exit
fi

regex=$1
shift

for svnroot in $@; do
    for path in $(svn ls --recursive $svnroot); do
        if [[ $path != */ ]]; then
            svn cat $svnroot/$path \
                | grep --label="$svnroot/$path" --with-filename $regex 
        fi
    done
done
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号