That's a compound line - it's running two commands at once through use of the backticks "`".
Like order of operations - the script will execute what's in the backticks first, and then send its output to the containing statement.
So first it executes
echo $file | sed 's/DIR1/DIR2/'
which is a non-elegant way to substitute all the occurances of "DIR1" in the $file (path) with "DIR2". In this case, DIR1 and DIR2 would be replaced with your source and target root folders.
The output of that statement is the modified file path to point to DIR2/path instead of DIR1/path, so the subsequent statement becomes:
cp DIR1/path DIR2/path
The end result is that a file from the source directory that was found by your 'find' command will be copied to the target directory in the same location. Here's an example of a "real" file as it's transformed by this script:
# we want to syncronize this file: /source/my/dir/testfile to /dest/my/dir/testfile
# so we'll change the script to look like this:
for file in `find /source/* -mtime 0 -name '*' -type f`; do
cp $file `echo $file | sed 's/source/dest/'`
The output of this program will be:
indicating that it copied that file (though it doesn't indicate where to) -- this behavior can easily be modified.
The end result is now you have a copy of the /source/my/dir/testfile in /dest/my/dir/.
So, I'll modify this script to be a little more verbose and a little more parameterized...
# Script to synchronize files modified today from $SRC to $DEST as
# specified by the first and second command-line parameters
SRC = $1
DEST = $2
echo Synchronizing $SRC to $DEST...
for file in `find $SRC/* -mtime 0 -name '*' -type f`; do
dfile = `echo $file | sed 's/$SRC/$DEST/'`
echo copying $file to $dfile
cp $file $dfile
echo Synchronization complete.
Now you can call the program thusly (saved as bsync.sh) using the previous example:
brion> sh bsync.sh /source /dest
Synchronizing /source to /dest...
copying /source/my/dir/testfile to /dest/my/dir/testfile
sed is a Stream EDitor that permits you to, among other things, substitute text in a stream with other text -- in this case, the $SRC with the $DEST directory names in the source file path.
Does that help?