I'm baffled by something in a small script I wrote. The purpose of the script is to compare 2 files on a system. Somehow a tree structure was copied and am fairly certain that the files are identical
The command line is as follows:
/filecomp.sh /home/daniel/Documents/workspace/www/
This is the script:
find $1 -name "*.*" | while read file
do
file2="/var${file:32}"
if diff $file $file2 >/dev/null ; then
rm $file
else
echo Different
fi
done
The variable file2 is defined by stripping out the path defined in $1 and adding '/var' to the front of it. The path would become /var/www/ and the same filename.
If I run the file with bash -x to echo the steps for debugging, it works fine. If I don't debug, then I receive an error of Bad Substition at line 10 (the last line of the script).