Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
test if file exists
Name: hernandez Date: January 13, 2003 at 04:51:11 Pacific OS: w98se CPU/Ram: 128
Comment:
I've written some script that checks to see if a file exists but it's not working properly. I'm in korn shell.
if [ -e $filename ] then file_menu #call the function file_menu else echo data file does not exist fi
i've tried this with dummy filenames and no matter what name i enter, it calls the function. it seems to ignore that the file doesn't exist.
Name: cdac Date: January 13, 2003 at 05:59:02 Pacific
Reply:
The code looks fine to me .
But try using switch -s. ( More helpful as is checks for the file size as well ).
regards
0
Response Number 2
Name: James Boothe Date: January 13, 2003 at 06:40:07 Pacific
Reply:
The -e is not valid on HP-UX:
-f does regular file exist? -x does executable file exist? -r does readable file exist? -w does writable file exist? -s does regular file gtr than size 0 exist?
0
Response Number 3
Name: hernandez Date: January 13, 2003 at 07:36:53 Pacific
Summary: Hello I have a shell script that runs 5 times a day and ftps to a remote server...i only want it to ftp if $FILE exists on the remote server...here is the script..please help ftp -n $HOST <<END_...
Summary: How to determine whether a file that you want to use exist or not using 'test' which gives return value when '$?' is typed? eg: if the file exist, then $? = 0 (true) but if the file doesn't exist...