#!/bin/sh # Substitute pattern in files # By Michalis Faloutsos if [ $# -eq 0 ] then echo "Usage : sub oldPattern newPattern files" echo "Example: sub john John Documnet.txt" exit 1 fi toChange=$1 toBecome=$2 # ignore the first two arguments shift shift myfile=$* #echo FILES: $myfile for file in $myfile do # sed is a file editing tool sed "s/$toChange/$toBecome/g" $myfile done