The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need to write a script in UNIX to find a file if another file exists mmdawg Shell Programming and Scripting 1 05-04-2008 11:40 PM
Check File Exists and compare to previous day file script rbknisely Shell Programming and Scripting 3 02-07-2008 11:53 AM
checking a connection still exists? fishman2001 IP Networking 2 12-14-2007 07:45 AM
File exists and is empty dstinsman UNIX for Dummies Questions & Answers 5 02-09-2006 11:05 AM
Please help me with this script meant for checking /etc/passwd if a name exists TRUEST Shell Programming and Scripting 4 03-04-2002 11:29 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-02-2008
ksmbabu ksmbabu is offline
Registered User
  
 

Join Date: Apr 2008
Location: Bangalore
Posts: 14
Checking the file if it exists

Hi

This will be useful who is looking for checking the files in a directory

#chmod 777 /cronacle/tools/teradata/opo/bin/file_check.sh
SUBJECT=`echo "File Not Found"`
SUBJECT1=`echo "File Found"`
#RECIPIENT=Madhu.Reddy@ge.com
cd /cronacle/tools/teradata/opo/bin
file_list=attach.sh
if [ -s $file_list ]
then
echo $file_list "$SUBJECT1" | mailx -s "$SUBJECT1" abc@abc.com
exit 1
else
echo $file_list "$SUBJECT" | mailx -s "$SUBJECT" abc@abc.com --mail id
exit 0
fi

Thanks
Babu
  #2 (permalink)  
Old 04-02-2008
KevinADC KevinADC is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2008
Posts: 731
I thought -e was the switch to use to see if a file exists?
  #3 (permalink)  
Old 04-02-2008
krishmaths krishmaths is offline
Registered User
  
 

Join Date: Sep 2006
Location: Mysore, India
Posts: 191
slight difference

Quoting from man test


Code:
-e FileName
            Returns a True exit value if the specified FileName exists.

-s FileName
            Returns a True exit value if the specified FileName exists and has a size greater than 0.

  #4 (permalink)  
Old 04-02-2008
ksmbabu ksmbabu is offline
Registered User
  
 

Join Date: Apr 2008
Location: Bangalore
Posts: 14
Checking the file if it exists

krishmaths is right for the option -s and -e
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:12 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0