If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Help with shell script??

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-12-04, 18:35
KingSix KingSix is offline
Registered User
 
Join Date: Apr 2004
Posts: 1
Help with shell script??

I need help with a shell script, maybe someone can help me out. For example lets say I have a list.conf file with a list of directories in it: usr/bin /ect and I must create an A1.sh file that reads the directories in the list.conf file and then scan those directories for any file that has been modified in the last day. If the file has been modified the shell script would send an email to an address with the directory or file that has been modified in the last day.

I know I must use the find command with -mtime +1 for the search, but I have no clue how to read the directories from the list.conf file or the proper syntax of the if statement to send an email with the list of modified files.

Please bare with me since I am very new to shell scripts...

any help would be greatly appreciated. Thanks in advanced.
Reply With Quote
  #2 (permalink)  
Old 04-13-04, 13:10
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
Try something like this (not fully tested) :
Code:
while read dir
do
   find $dir -mtime -1 | xargs ls -l > /tmp/$$
   if [ -s /tmp/$$ ] ; then
      {
        echo "Directory : $dir"
        echo ""
        echo "The following directories or files have been modified"
        echo "during the last 24 hours."
        echo ""
        cat /tmp/$$
      } | mail -s "Modified files" user
   fi
done < list.conf
rm -f /tmp/$$
__________________
Jean-Pierre.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On