IDG Answers is a community of experts who are passionate about technology. Ask a question or answer one below.
#!/bin/bash recip="email@example.com" dir="/usr/data" for file in `ls $dir` do if [ ! -f $1.bak ]; then cp $1 $1.bak exit fi if [ `diff $1 $1.bak` ]; then diff tryme tryme.bak > /tmp/diff$$ cat /tmp/diff$$ | mailx -s "file changed" $recip echo "`date`: $file changes noted" >> /var/log/filechanges.log ls -l $file >> /var/log/filechanges.log rm /tmp/diff$$ fi done
Thank you very much... But I have some questions.... (1)if you are giving
for file in `ls $dir`
then what is the use of "$1" because the list of file will be store in variable file...
(2)diff tryme tryme.bak > /tmp/diff$$ ........... what is the use of this command..??
and can we use sum,cksum and md5sum for the given problem..??