Thursday, March 11, 2010

Shell script for replacing multiple partial strings in multiple files

I wrote a very simple script to handle a complex replacing in a lot of files. Use with care!


#!/bin/bash

# This script replaces multiple partial strings in multiple files

for n in strpart1 strpart2 strpart3
do
exec perl -pi -e 's/firstpart${n}secondpart/newfirstpart${n}newsecondpart/g' *.htm
done

No comments:

Post a Comment