$file_name, not file_name
ditto for the other variables
use "sed -e" not just "sed"
and change $file.new to ${file}.new just to be safe
Edit: So many problems, so little text. ;-)
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
Masijade answered your question but i'd like to throw something else in there. You should add checks for your arguments on the command line and verify the file exists:
#!/bin/bash
file_name=$1
old_templet=$2
new_templet=$3
if [ "$3" = "" ]; then
echo "usage: ${0} <file_name> <new_templet> <old_templet>"
exit 1
fi
if ! test -f ./${file_name}; then
echo "file not found"
exit 1
fi
if test -f ./${file_name}.new; then
rm ./${file_name}.new
fi
sed "s/${old_templet}/${new_templet}/g" ${file_name} >> ${file_name}.new
sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735