#!/usr/local/bin/perl -w use strict; sub Usage; my $rArgs = ""; my $options = "-pi"; if ( !$ARGV[2] ) { Usage("Not enough inputs"); } if ( $ARGV[3] ) { $rArgs = $ARGV[3]; } foreach my $arg (@ARGV) { $arg =~ s#'##g; } if ( $rArgs =~ /s/ ) { $options .= " -0777"; } my $cmd = "find -name '*" . $ARGV[0] . "' | xargs perl ". $options. " -e 's#" . $ARGV[1] . "#" . $ARGV[2] . "#" . $rArgs . "'"; print "performing: $cmd\n"; system($cmd); print "Done\n"; sub Usage { print "replace (c)2002 Jeremy Andrus\nUsage:\n" . "\treplace [file_type] [search text] [replace_text] {regExp options}\n\n" . "e.g.\n\treplace .html '' '' g\n\twould replace all instances" . "of \"\" with \"\n\n"; exit(0); }