Sponsored Content
Full Discussion: check if file is empty
Top Forums Shell Programming and Scripting check if file is empty Post 302128403 by lapisguy on Tuesday 24th of July 2007 03:24:05 PM
Old 07-24-2007
Question What if I want ot check for a file size greater than say 487

I have a requirement where if file size is 487 then ignore it otherwise put into e-mail script? I can do it using -s but it does only if file is empty...
any clue on this please???
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to check for empty file in Perl?

Hi, May I know how to check for empty file in Perl. Iam missing something, somewhere. #!/usr/bin/perl my $open_dir = '/path/'; my $file; my $ma = "abc_.*.\.psv\$" opendir(VAR, $open_dir) or die "Can't open $oepn_dir: $!\n"; while( defined ($file = readdir VAR) ) #read all... (1 Reply)
Discussion started by: deepakwins
1 Replies

2. UNIX for Dummies Questions & Answers

How to check if a file is empty?

Hi Masters..... I have problem !!! I need to check number of records in a file and if it is zero or file is empty i need to do some task. if ; then echo "File s empty" else echo "Not empty" fi so how to check this condition. I used wc -l < filename.txt => 1 for zero records same result... (1 Reply)
Discussion started by: shreekrishnagd
1 Replies

3. UNIX for Dummies Questions & Answers

to check if file is empty or not and return a non zero value

Hi All, I am new to unix worldd . I need to check a file1 if its empty or not. If its empty then return a non zero value say 99 could you pls let me know the perl script for this. (2 Replies)
Discussion started by: mavesum
2 Replies

4. Shell Programming and Scripting

Need to check for empty file in C shell script

I am running a C shell script. I have an output file from a previous step and I need to run "something" in the next step to check if the file is empty. If the file is empty, then the job script should finish EOJ. If the file is not empty then the job script should abend. Please help Thanks. (4 Replies)
Discussion started by: jclanc8
4 Replies

5. Shell Programming and Scripting

Check if a text file is empty or not (using ls -s)

Hello, I want to make a script which says if a text file is empty or not. I tried two ways of making it, but I have problems with both of them. Now I think that the better way is the ls -s solution (considering that an empty text file has a 0 weight, because "cat file.txt" fails when file is... (4 Replies)
Discussion started by: Link_
4 Replies

6. Shell Programming and Scripting

Condition to check whether configuration file is empty or not?

CMD=$(find "${Release_Container}" -iname "${Release_Name}"_Release.txt) for i in `cat $CMD` do if ];then cd ${Sandbox_dir} CMD1=$(find "${Sandbox_dir}"/* -iname "${Release_Name}" -type d | awk -F/ '{print $(NF)}' | head -1 ) if ];then echo -e "################### CHECKOUT START... (2 Replies)
Discussion started by: anuragpgtgerman
2 Replies

7. UNIX for Dummies Questions & Answers

Check if file is empty with variables, bash

Hello again! I have some trouble with scripting in bash. In the following script I read from a folder with the files line0_Ux.xy line1_Ux.xy line2_Ux.xy . . . Some of the files are empty. For those I would like to print a "0" in list. I think the problem with the code is that... (4 Replies)
Discussion started by: bjoern456
4 Replies

8. Shell Programming and Scripting

Empty file check

Hi gurus , I have two files and i want to perform different action based on the condition if both or either is empty If then Do something elif then do something elif then do something else do something fi I have tried the below bt its not... (4 Replies)
Discussion started by: r_t_1601
4 Replies

9. Shell Programming and Scripting

How to check if the file is empty or has blank space.?

Hi, I am using KSH. I am trying to check if the output file is empty or not. I tried with ] but what i see is my file is empty but still manages to have a size of 1 instead of 0. But my file doesnot have anything its empty. I am not sure how to check this. can any one help? (10 Replies)
Discussion started by: Sharma331
10 Replies

10. Shell Programming and Scripting

To check whether the file is empty or not in shell script (sh)

Hi All, I need to check a file whether it exists and also whether it is empty or not. I have a code for this but it is not working as per my requirement. Can anyone pls suggest me on this. function funcFLSanityCheck { if then echo "${varFLSentFileListPath}/${varFLSentFileName}... (7 Replies)
Discussion started by: Arun1992
7 Replies
Email::Filter(3pm)					User Contributed Perl Documentation					Email::Filter(3pm)

NAME
Email::Filter - Library for creating easy email filters SYNOPSIS
use Email::Filter; my $mail = Email::Filter->new(emergency => "~/emergency_mbox"); $mail->pipe("listgate", "p5p") if $mail->from =~ /perl5-porters/; $mail->accept("perl") if $mail->from =~ /perl/; $mail->reject("We do not accept spam") if $mail->subject =~ /enlarge/; $mail->ignore if $mail->subject =~ /boring/i; ... $mail->exit(0); $mail->accept("~/Mail/Archive/backup"); $mail->exit(1); $mail->accept() DESCRIPTION
This is another module produced by the "Perl Email Project", a reaction against the complexity and increasing bugginess of the "Mail::*" modules. It replaces "Mail::Audit", and allows you to write programs describing how your mail should be filtered. TRIGGERS
Users of "Mail::Audit" will note that this class is much leaner than the one it replaces. For instance, it has no logging; the concept of "local options" has gone away, and so on. This is a deliberate design decision to make the class as simple and maintainable as possible. To make up for this, however, "Email::Filter" contains a trigger mechanism provided by Class::Trigger, to allow you to add your own functionality. You do this by calling the "add_trigger" method: Email::Filter->add_trigger( after_accept => &log_accept ); Hopefully this will also help subclassers. The methods below will list which triggers they provide. ERROR RECOVERY
If something bad happens during the "accept" or "pipe" method, or the "Email::Filter" object gets destroyed without being properly handled, then a fail-safe error recovery process is called. This first checks for the existence of the "emergency" setting, and tries to deliver to that mailbox. If there is no emergency mailbox or that delivery failed, then the program will either exit with a temporary failure error code, queuing the mail for redelivery later, or produce a warning to standard error, depending on the status of the "exit" setting. METHODS
new Email::Filter->new(); # Read from STDIN Email::Filter->new(data => $string); # Read from string Email::Filter->new(emergency => "~simon/urgh"); # Deliver here in case of error This takes an email either from standard input, the usual case when called as a mail filter, or from a string. You may also provide an "emergency" option, which is a filename to deliver the mail to if it couldn't, for some reason, be handled properly. Hint If you put your constructor in a "BEGIN" block, like so: use Email::Filter; BEGIN { $item = Email::Filter->new(emergency => "~simon/urgh"); } right at the top of your mail filter script, you'll even be protected from losing mail even in the case of syntax errors in your script. How neat is that? This method provides the "new" trigger, called once an object is instantiated. exit $mail->exit(1|0); Sets or clears the 'exit' flag which determines whether or not the following methods exit after successful completion. The sense-inverted 'noexit' method is also provided for backwards compatibility with "Mail::Audit", but setting "noexit" to "yes" got a bit mind-bending after a while. simple $mail->simple(); Gets and sets the underlying "Email::Simple" object for this filter; see Email::Simple for more details. header $mail->header("X-Something") Returns the specified mail headers. In scalar context, returns the first such header; in list context, returns them all. body $mail->body() Returns the body text of the email from to cc bcc subject received $mail-><header>() Convenience accessors for "header($header)" ignore Ignores this mail, exiting unconditionally unless "exit" has been set to false. This method provides the "ignore" trigger. accept $mail->accept(); $mail->accept(@where); Accepts the mail into a given mailbox or mailboxes. Unix "~/" and "~user/" prefices are resolved. If no mailbox is given, the default is determined according to Email::LocalDelivery: $ENV{MAIL}, /var/spool/mail/you, /var/mail/you, or ~you/Maildir/. This provides the "before_accept" and "after_accept" triggers, and exits unless "exit" has been set to false. reject $mail->reject("Go away!"); This rejects the email; if called in a pipe from a mail transport agent, (such as in a ~/.forward file) the mail will be bounced back to the sender as undeliverable. If a reason is given, this will be included in the bounce. This calls the "reject" trigger. "exit" has no effect here. pipe $mail->pipe(qw[sendmail foo@bar.com]); Pipes the mail to an external program, returning the standard output from that program if "exit" has been set to false. The program and each of its arguments must be supplied in a list. This allows you to do things like: $mail->exit(0); $mail->simple(Email::Simple->new($mail->pipe("spamassassin"))); $mail->exit(1); in the absence of decent "Mail::SpamAssassin" support. If the program returns a non-zero exit code, the behaviour is dependent on the status of the "exit" flag. If this flag is set to true (the default), then "Email::Filter" tries to recover. (See "ERROR RECOVERY") If not, nothing is returned. PERL EMAIL PROJECT
This module is maintained by the Perl Email Project <http://emailproject.perl.org/wiki/Email::Filter> COPYRIGHT
Copyright 2003, Simon Cozens <simon@cpan.org> LICENSE
You may use this module under the terms of the BSD, Artistic, or GPL licenses, any version. AUTHOR
Casey West, "casey@geeknest.com" Simon Cozens, "simon@cpan.org" perl v5.10.0 2008-09-15 Email::Filter(3pm)
All times are GMT -4. The time now is 02:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy