Find all working copies of subversion on a machine

How can I use findunix utility to find all working copies on a machine? For example, I can use the command find / -name .svn -type d, but it displays all redundant results (many subfolders), while I only need the parent directory of the working copy to display.

There is a question related to this, but in my case it really does not help: How to find the root folder for a given working copy of a subtree

+3
source share
4 answers

maybe something like this?

#!/bin/bash
if [ -d "$1/.svn" ]; then
        echo $1
else
        for d in $1/*
        do
                if [ -d "$d" ]; then
                        ( $0 $d )
                fi;
        done
fi;

, , - find_svn.sh, ./find_svn.sh /var/www ( , ... , - ).

+5

Update 3 - , .svn . .


Perl :

find -s . -ipath *.svn | perl -lne's!/\.svn$!!i;$a&&/^$a/||print$a=$_'

: svn, /.svn, , , .

: :

$ find .
.
./1
./1/.svn
./1/1
./1/1/.svn
./2
./2/.svn
./3

./1
./2
+6

GNU find/sort

find /path -type f -name ".svn*" -printf "%h\n"  | sort -u
+1

The following works are just fine for me. It also finds all rare checks (or nested working copies).

find $PWD -type d -wholename "*/.svn" |
while read path
do
    path=${path%%/.svn}
    wcr=$(svn info ${path} 2>/dev/null | perl -F"/:\s/" -le '{ print $F[1] if $F[0] =~ /^Working Copy Root/;  }')
    [ "$path" = "$wcr" ] && {
        echo -e "\n  WC Root $path"; svn stat -qu $path;
        }
done
+1
source

Source: https://habr.com/ru/post/1729928/


All Articles