The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 05-01-2008
bakunin bakunin is offline
Bughunter Extraordinaire
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,035
I would like to add to what era said that - AIX or not - this is the most awkward way to check for the existence of a file i have ever seen. Why not use something like:

Code:
if [ -f /your/file ] ; then
     <whatever you want to do with the file here>
else
     print -u2 "ERROR: file /your/file doe not exist!"
fi
"test -f" tests if the the file exists and is a regular file (not a directory, device file, etc.)

"test -r" tests if it exists and is readable

"test -w" tests if it exists and is writable

etc., see to man page for "test"

I hope this helps.

bakunin
Reply With Quote