![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Checking the existence of a file.. | igandu | Shell Programming and Scripting | 7 | 06-13-2007 12:47 AM |
| checking file existence | DILEEP410 | Shell Programming and Scripting | 3 | 01-24-2007 09:43 AM |
| File existence problem | anormal | UNIX for Dummies Questions & Answers | 2 | 05-15-2006 09:54 AM |
| File existence | mpang_ | Shell Programming and Scripting | 2 | 03-27-2006 08:27 AM |
| Searching for the existence of a file | sbhan | UNIX for Advanced & Expert Users | 2 | 10-14-2002 01:02 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I wasn't sure if I should post it here of in the Shell Script category, but I figured it was definitely a newbie question.
I'm trying to write a script that will check for the existence of a specific file (or for any files within the directory) and then take specific actions. I've removed all the extra processing in the loop, comments, and variables. I'm just trying to get my basic loop to work. I did check the FAQ's but I think this is even too basic a question for there. Anyone's assistance with this would be appreciated. #!/bin/sh if (test.dat exists in current directory) then echo "test.dat exists!" |mail noone@domain.com else echo "test.dat does not exist!" |mail noone@domain.com fi |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Use the following if
if [ -f file_name ] then # File Exists else # File does not exist fi |
|
#3
|
|||
|
|||
|
What does the -f mean before the filename? I did receive and proper response e-mail when I used this. I also just tried "ls filename" and had the same result.
If I were to look for the existence of any file in that directory, would I just replace the filename with * ? Thanks again! |
|||
| Google The UNIX and Linux Forums |