#!/usr/bin/perl # Global search and replace. Greps all files in the dir # for a string and replaces it. # Usage glob_rep search_string replace_string. $search = @ARGV[0]; $replace = @ARGV[1]; @files = `grep -l $search *`; @files = grep !/not permitted/, @files; foreach $file (@files) { open (FILE, $file); @lines = ; close FILE; open (TEMP, ">temporary.file.name"); foreach $line (@lines) { $line =~ s/$search/$replace/g ; print TEMP $line; } close TEMP; `mv -f temporary.file.name $file`; }