Help to Monitor the existence of a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help to Monitor the existence of a file
# 1  
Old 11-16-2009
Help to Monitor the existence of a file

Hi Folks,
Please tell me the unix shell script command to check for the existence of some .done file in a location on the UNIX server.
# 2  
Old 11-16-2009
Using a test with one of these that suits you:

Code:
i.e.
if [ -r SomeFile ]; then ...
...
fi



       -a file
              Same as -e below.  This is obsolete.
       -b file
              True, if file exists and is a block special file.
       -c file
              True, if file exists and is a character special file.
       -d file
              True, if file exists and is a directory.
       -e file
              True, if file exists.
       -f file
              True, if file exists and is an ordinary file.
       -g file
              True, if file exists and it has its setgid bit set.
       -k file
              True, if file exists and it has its sticky bit set.
       -p file
              True, if file exists and is a fifo special file or a pipe.
       -r file
              True, if file exists and is readable by current process.
       -s file
              True, if file exists and has size greater than zero.
       -t fildes
              True, if file descriptor number fildes is  open  and  associated
              with a terminal device.
       -u file
              True, if file exists and it has its setuid bit set.
       -w file
              True, if file exists and is writable by current process.
       -x file
              True,  if  file exists and is executable by current process.  If
              file exists and is a directory, then true if the current process
              has permission to search in the directory.
       -L file
              True, if file exists and is a symbolic link.
       -h file
              True, if file exists and is a symbolic link.
       -N file
              True,  if  file exists and the modification time is greater than
              the last access time.
       -O file
              True, if file exists and is owned by the effective  user  id  of
              this process.
       -G file
              True,  if  file exists and its group matches the effective group
              id of this process.
       -S file
              True, if file exists and is a socket.
       file1 -nt file2
              True, if file1 exists and file2 does not, or file1 is newer than
              file2.
       file1 -ot file2
              True, if file2 exists and file1 does not, or file1 is older than
              file2.
       file1 -ef file2
              True, if file1 and file2 exist and refer to the same file.

These are for ksh, other shells may vary. Check the man page.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File existence

Hope someone can help me on this In a directory ,files are dynamically generated.I need a script to do the following if files are not received for more than 2 hours or if the received file is empty then do something How can I put that in a script.Thank you eg. in cd /dir_name the... (13 Replies)
Discussion started by: haadiya
13 Replies

2. Shell Programming and Scripting

Checking for the file existence

Hi, I have written a script to validate the data file by referreing to the configurtion file. And moving the validated good records and bad records into HDFS. Suppose after 15 mins if i receive one more data fie,then after validation the good and bad records shold be stored in hadoop with the... (8 Replies)
Discussion started by: shree11
8 Replies

3. Shell Programming and Scripting

Script to check for the file existence, if file exists it should echo the no of modified days

Hi, I am looking for a shell script with the following. 1. It should check whether a particular file exists in a location #!/bin/sh if ; then echo "xxx.txt File Exists" else echo "File Not Found" fi 2. If file exists, it should check for the modified date and run a command... (2 Replies)
Discussion started by: karthikeyan_mac
2 Replies

4. Shell Programming and Scripting

Existence of a string in a file

Hi, I want to know whether a string or variable is exists in a perticular file or not. I want to use IF command in cshell. I am not sure how to use it. can any one help me.. (2 Replies)
Discussion started by: arup1980
2 Replies

5. Shell Programming and Scripting

File existence

Hi I'm using the below command in shell script to check for file exists in the path if ..... fi path and test are variables path and the file exists but the commands inside if condition is executed (! operator used) Is the above way of checking for file existence is correct? ... (4 Replies)
Discussion started by: vinoth_kumar
4 Replies

6. Shell Programming and Scripting

Parse file from remote server to calculate count of string existence in that file

Hi I need to parse the file of same name which exist on different servers and calculate the count of string existed in both files. Say a file abc.log exist on 2 servers. I want to search for string "test" on both files and calculate the total count of search string's existence. For... (6 Replies)
Discussion started by: poweroflinux
6 Replies

7. Shell Programming and Scripting

File existence and increment

count=0; while read line; do ] && let count=count+1; done < file_name.txt echo echo "$count of 10 files found " echo The scenario is a follows : I have a file which contains a list of filenames present in particular directory . I am checking fo the existence of the file and... (5 Replies)
Discussion started by: ultimatix
5 Replies

8. AIX

Check for File Existence

I have requirement where i need to search for files which start with SALESORDER and PURCHASEORDER. i need to process the files with SALESORDER first and then PURCHASEORDER. If SALESORDER files are not there i dont want to process PURCHASEORDER and i want to come out of script. I have written a code... (4 Replies)
Discussion started by: dsdev_123
4 Replies

9. Shell Programming and Scripting

File existence using ls

Hi I want to check a particular file is available or not. But i know only the pattern of that file sat AB1234*.txt.I need the latest file name and it ll be used in the script. How can i do this using ls -ltr command. Thanks, LathishSundar V (2 Replies)
Discussion started by: lathish
2 Replies

10. Shell Programming and Scripting

File existence

Hey all, I have total new with shell scripting so I don't know if what I need to do even possible, here it is...for a duration of time (say...1 hour) I need to check for the existence of a particular file, if it exists then I will invoke a java program or I will continue to check until a)... (2 Replies)
Discussion started by: mpang_
2 Replies
Login or Register to Ask a Question