I probably won’t be blogging from now until the end of next week. I’ll post an entry or two if I manage to get internet access, but it’s very likely there won’t be any where I’ll be.
If you want to search and replace text among lots of files, Perl can make your life a lot simpler. Here is a script to replace the string ‘old_text’ with ‘new_text’ in any file ending with .txt. The script would have to be run from the same directory as the files which have the text you want replaced.
#!/usr/bin/perl
@files = <*.txt>;
foreach $file ( @files )
{
system( "perl -p -i -e 's/old_text/new_text/g' $file" );
}
In order to use this code, copy it to a file and save it, then run the following command on the file.
chmod 755 <filename>