#!/bin/bash #Use the g command to indicate to sed that it should examine the entire line instead of stopping at the first occurrence of your string: echo Replacing every occurence of "$2" with "$3" within the listed files: find . -name $1 find . -name $1 -exec sed -i.old "s/$2/$3/g" {} \;