Page 1 of 1

Searching specific path

Posted: Thu May 01, 2008 10:23 am
by batsys
Is it possible in WildEdit to search files that lay on a specific path or path fragment?

Here's the problem, our beloved IT department has changed our CVS server's name and I need to update all references to the CVS instance. These are kept in a file called 'Root' that lives in a folder called 'CVS' in all the directories that are managed by CVS.

The actual replace is a simple edit that swaps "sunserv09" for "cvs" in the file 'Root'. Is it possible to get WildEdit to only look for

CVS\Root

i.e., files called 'Root' that are in a directory called 'CVS' and ignore any file called 'Root' in any other parent directory?

Posted: Sat May 03, 2008 4:51 pm
by ben_josephs
I don't believe this is possible in WildEdit.

But if you use CVS, you should have no trouble with a scripting language, for example, Perl:

Code: Select all

use File::Find ;

my $ext = '.orig' ;

find \&doIt, '.' ;

sub doIt ()
{
  if ( $File::Find::dir =~ m|/CVS$| && $_ eq 'Root' )
  {
    print "$File::Find::name\n" ;

    my $new =  $_        ;
    my $bup = "$new$ext" ;

    rename $new, $bup or die "Can't back up $File::Find::name: $!\n" ;

    open BUP, "<$bup" or die "Can't open $File::Find::name$ext: $!\n" ;
    open NEW, ">$new" or die "Can't open $File::Find::name: $!\n" ;

    for my $line ( <BUP> )
    {
      $line =~ s/cvs/sunserv09/ ;
      print NEW $line ;
    }

    close NEW ;
    close BUP ;
  }
}

Thanks

Posted: Tue May 06, 2008 10:29 am
by batsys
Thanks for the input Ben. In the end I wrote a Python script to do much the same sort of thing.