Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004

    Unanswered: 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 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.

  2. #2
    Join Date
    Jan 2004
    Bordeaux, France
    Try something like this (not fully tested) :
    while read dir
       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
    done < list.conf
    rm -f /tmp/$$

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts