The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > AIX
Google UNIX.COM


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to check the existence of a file using korn shell? karthikprasathk AIX 3 06-19-2008 02:51 AM
how to check the existence of a file during ftp using korn shell? karthikprasathk AIX 1 06-19-2008 12:20 AM
Csh to check for existence of file Raynon Shell Programming and Scripting 9 12-05-2007 05:20 PM
How to check the file existence using shell scripting in Solaris-10 krevathi1912 SUN Solaris 2 11-26-2007 01:07 AM
Variable check for existence ? samit_9999 UNIX for Dummies Questions & Answers 2 12-05-2006 01:15 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-25-2008
Registered User
 

Join Date: Jan 2008
Posts: 8
check for file existence

Hello

I am having a requirement like if there is no file in the directory then i need a message to pop on after the execution of the script.

My script basically does for File in `ls -t $DIRECTORY | tail -1`;
if there is no file the DIRECTORY then the script is simply exiting with out giving any message but i want a message to pop on the screen with non-zero exit code.

Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-26-2008
Registered User
 

Join Date: Sep 2007
Location: Koblenz, Germany
Posts: 571
There is a shell scripting subforum here - this one here is specific for AIX.
Reply With Quote
  #3 (permalink)  
Old 06-26-2008
joeyg's Avatar
premier etoile de match
 

Join Date: Dec 2007
Location: Home of world champion Boston Celtics
Posts: 530
Wink Even though scripting, and not AIX specific, here is something to ponder

I am looking for 'regular' files with the grep, and seeing a file count
Code:
> ls -l ./raw | grep "^-" | wc -l
45
> ls -l ./raw1 | grep "^-" | wc -l
0
Now, take a look at the following two examples and commands
Code:
> numf=$(ls -l ./raw | grep "^-" | wc -l)
> if [ $numf -gt 0 ] ; then echo "Files Present"; else  echo "No Files"; fi
Files Present
> numf=$(ls -l ./raw1 | grep "^-" | wc -l)
> if [ $numf -gt 0 ] ; then echo "Files Present"; else  echo "No Files"; fi
No Files
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:35 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0