Sponsored Content
Top Forums Shell Programming and Scripting Shell script to monitor new file in a directory and mail the file content Post 302783005 by Yoda on Tuesday 19th of March 2013 06:30:57 PM
Old 03-19-2013
Another option is to have a file with the list of files that you handled and check against it each time you run your script:
Code:
for file in ${dir}/*
do
        [[ "$file" =~ handled.dat ]] && continue
        if grep -w "$file" "${dir}/handled.dat" > /dev/null 2> /dev/null
        then
                continue
        fi
        mailx -s "Subject" user@domain.com < "$file"
        printf "%s\n" "$file" | tee -a "${dir}/handled.dat"
done

This User Gave Thanks to Yoda For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script to edit the content of a file

Hi I need some help using shell script to edit a file. My original file has the following format: /txt/email/myemail.txt /txt/email/myemail2.txt /pdf/email/myemail.pdf /pdf/email/myemail2.pdf /doc/email/myemail.doc /doc/email/myemail2.doc I need to read each line. If the path is... (3 Replies)
Discussion started by: tiger99
3 Replies

2. Shell Programming and Scripting

shell script to search content of file with timestamps in the directory

hello, i want to make a script to search the file contents in my home directory by a given date and output me the line that has the date... (10 Replies)
Discussion started by: psychobeauty
10 Replies

3. UNIX for Advanced & Expert Users

Reading a file and sending mail based on content of the file

Hi Gurus, I am having an requirement. i have to read a list file which contains file names and send mail to different users based on the files in the list file. eg. if file a.txt exists then send a mail to a@a.com simillary for b.txt,c.txt etc. Thanks for your help, Nimu (6 Replies)
Discussion started by: nimu1979
6 Replies

4. Shell Programming and Scripting

Delete content of file 1 in file 2 with shell script

OK, best is I explain what the operating enviroment is. Linux, but Motomagx. It is a Linux operated mobile phone, Motorola V8. I am writting a shell script, but got stuck. I have to delete the complete content of file 1 in file 2. I have attached the 2 files. You can see that the content of... (2 Replies)
Discussion started by: rasputin007
2 Replies

5. Shell Programming and Scripting

Monitor file generation for an hour using Korn shell script

Hi, I am new to this unix scripting, I got a requirement like.. Files with *.XML extension will be generating in a /home/sample/ folder for every 15 mins. I need to monitor those files in that particular folder for every hour. If no file has been generated in that particular folder for an... (7 Replies)
Discussion started by: siri_886
7 Replies

6. Shell Programming and Scripting

Shell script to remove some content in a file

How can I remove all data that contain domain e.g zzgh@something.com, sdd@something.com.my and gg@something.my in one file? so that i only have data without the domain in the file. Here is the file structure "test.out" more test.out 1 zzztop@b.com 1 zzzulll 1 zzzullll@s.com.my ... (4 Replies)
Discussion started by: Mr_47
4 Replies

7. Shell Programming and Scripting

Looking for shell script to monitor CPU utilization and send mail once exceed 75%

Dear Group, I'm look for shell script to Monitor CPU usage and send mail once it exceed 75% I'm running Suse10.4. (3 Replies)
Discussion started by: clfever
3 Replies

8. Shell Programming and Scripting

Script to process file from a directory and grep the required content and print

Hi All, below script reads the perticular files from the directory. Am trying to fetch status and print them in the required format. It needs to read line and search for string "Passed/Failed" and print them under correct sub header. script : BASE_DIR=/tmp/test/REPORT/CollectReport #... (16 Replies)
Discussion started by: Optimus81
16 Replies

9. Shell Programming and Scripting

Shell Script to Dynamically Extract file content based on Parameters from a pdf file

Hi Guru's, I am new to shell scripting. I have a unique requirement: The system generates a single pdf(/tmp/ABC.pdf) file with Invoices for Multiple Customers, the format is something like this: Page1 >> Customer 1 >>Invoice1 + invoice 2 >> Page1 end Page2 >> Customer 2 >>Invoice 3 + Invoice 4... (3 Replies)
Discussion started by: DIps
3 Replies

10. Shell Programming and Scripting

Monitor a file and send mail

I want to monitor the maillog file in real time and send a mail when a certain grep condition is met. Every time the grep condition is met a mail will be sent. I wish to ignore all grep conditions 30 mins after each mail and thereafter continue monitoring. For example: Condition is met, mail... (1 Reply)
Discussion started by: proactiveaditya
1 Replies
BP_INDEX(1p)						User Contributed Perl Documentation					      BP_INDEX(1p)

NAME
bp_index.pl - indexes files for use by bp_fetch.pl SYNOPSIS
bp_index.pl index_name file1 file2 etc. DESCRIPTION
bp_index.pl builds a bioperl index for the sequence files given in the argument list, under the index name. For example bp_index.pl nrdb /data/nrdb/nrdb.fasta would build an index called 'nrdb' as the index name for the file nrdb.fasta, and bp_index.pl -fmt EMBL swiss /data/swiss/*.dat would build an index called swiss for all the files in /data/swiss which end in .dat which are in EMBL format. The indexes are built using the Bio/Index/* modules, in particular, Bio::Index::EMBL and the Bio::Index::Fasta modules. Any script which uses these modules can use the index. A good example script is bp_fetch which fetches sequences and pipes them to STDOUT, for example bp_fetch swiss:ROA1_HUMAN gets the ROA1_HUMAN sequence from the swiss index and writes it as fasta format on STDOUT. OPTIONS
-fmt <format> - Fasta (default), swiss or EMBL -dir <dir> - directory where the index files are found (overrides BIOPERL_INDEX environment variable) Options for expert use -type <db_type> - DBM_file type. (overrides BIOPERL_INDEX_TYPE environment variable) -v - report every index addition (debugging) ENVIRONMENT
bp_index and bp_fetch coordinate where the databases lie using the enviroment variable BIOPERL_INDEX. This can be overridden using the -dir option. There is no default value, so you must use the -dir option or set BIOPERL_INDEX. The DB type is coordinated with BIOPERL_INDEX_TYPE which if it is not there, defaults to whatever the bioperl modules have installed, which itself defaults to SDBM_File. USING IT YOURSELF
bp_index.pl is a script that drives the Index modules. If you want to use this script heavily in your work, if it is Perl based, it is almost certainly better to look at the code in this script and copy it across (probably you will be more likely to want to use the bp_fetch code). EXTENDING IT
bp_index is just a wrapper around James Gilbert's excellent Index modules found in bioperl FEEDBACK
Mailing Lists User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing list. Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bioperl.org/wiki/Mailing_lists - About the mailing lists Reporting Bugs Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via the web: https://redmine.open-bio.org/projects/bioperl/ AUTHOR - Ewan Birney Ewan Birney <birney@ebi.ac.uk> perl v5.14.2 2012-03-02 BP_INDEX(1p)
All times are GMT -4. The time now is 06:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy