PDA

View Full Version : Hard editor wanted



The-REV
15th December 2006, 09:16 PM
Hi Folks.
I'm seeking for a Linux native text editor for programmers that is capable to open without problems around over 300 web pages at the same time and then does search & replace in all of them in order to update my principal website using Fedora Core 6. Please don't suggest me Emacs or VIM, OK? Any help on this issue will be sincerely appreciated...Some Window$ apps running on Linux by CrossOver does this task fine but the problem is I'm looking for a Linux native editor in order to suck only few CPU.

Aewyn
16th December 2006, 11:17 AM
Sounds like a task that one would be able to perform much more efficiently using the commandline.

If I had to do something like this I would probably try googling for info/tutorials on find and sed.

pete_1967
16th December 2006, 02:20 PM
#!/usr/bin/env perl

use File::Find;
use warnings;
use strict;

my @directories;
my ($find, $replace, $dirPath, $fileRegexp) = @ARGV;
my $counter = 0;
# my $operations = 0;

if(! $fileRegexp ) {
$fileRegexp = '.*';
}

print "find: $find replace: $replace in directory $dirPath in files matching $fileRegexp\n";

if (! $find || ! $replace){
die "takes two strings containing regexp expressions. Use quotes around them.\n";
}

if ($dirPath) {
@directories = ($dirPath);
} else {
@directories = ('.');
}

find(\&processFile, @directories);
print "$counter files touched\n";
print "this command used: perl -pi -e 's/$find/$replace/g' $dirPath $fileRegexp \n";

sub processFile() {
#Exclude CVS directories
unless($File::Find::name =~ /CVS/) {
if ( $_ =~ /$fileRegexp/ && ! -d) {
print $File::Find::name, -d && '/', "\n";
`perl -pi -e 's/$find/$replace/g' $_`;
$counter++;
} # end if
} # end unless
} # end sub