Save this in a file named script.sh:
# In this case, the string "hello" is replaced for "hello world" in all .txt files, renaming the
# read files with .txt.old.
for i in *.txt; do
mv $i $i.old
sed "s/hello/hello\/world/g" $i.old > $i
Don't forget to give the script the execution permission.
$ chmod +x script.php