Test for existence of files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Test for existence of files
# 1  
Old 12-02-2010
Test for existence of files

Hello,
Can you please help me to see if log files exist in a directory?
I need to scan logs in different directories, so I am using an array to change dynamically.
I need help in the if [ ........*.log........... ] test statement
Code:
dir[1]=/logs/MSD
dir[2]=/logs/UPD
countA=1
while (( countA <= ${#dir[*]} ))
do
   cd ${dir[countA]}
   if [.............]
   then
      echo NO LOGS FOUND
   else
      grep ORA *.log | uniq
fi
((countA +=1))
done

Thank you in advance

Last edited by vbe; 12-02-2010 at 09:42 AM.. Reason: code tags please
# 2  
Old 12-02-2010
Code:
if [ -f *.log ]

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check the Files existence

Hi I have a requirement to check whether the files exists, then it will call other steps in shell script. I did ls *.csv|wc -l if then checking the count of the files should be more than 1 then it will call other steps. I am getting the error that too many arguements as there n... (13 Replies)
Discussion started by: cnrj
13 Replies

2. Shell Programming and Scripting

Check for the existence and add them from 2 different files

Hi, I have two files file1: ALEX DANY GARY TOM MARY HARRIS file2: ALEX 3 ALEX 5 ALEX 0 ALEX 1 ALEX 0 DANY 2 (2 Replies)
Discussion started by: Diya123
2 Replies

3. Shell Programming and Scripting

test for existence of files with same extension

Hi, I am checking for existence of files with the same extensions #! /usr/bin/ksh txtfiles = '*.txt' if then cp ${dirpath}/${txtfiles} ${dir2path} fi I am getting the following error line 5: [: too many arguments for the if check condition (4 Replies)
Discussion started by: chen.sara
4 Replies

4. Solaris

How to test the existence of trailer record

SunOS 5.10 Generic_142900-15 sun4v sparc SUNW,T5240 I have a script that needs to test a file for the existence of a trailer record. Is there a command and is a header and trailer differect record type? Thanks in advance (1 Reply)
Discussion started by: Harleyrci
1 Replies

5. Shell Programming and Scripting

Test File for Existence with Whitespaces in Path

Hi Everyone! I'm quite new to shell scripting so this might be trivial, though 3 days of struggle and search didn't help to solve the problem: I want to look for files called '*HUN*' in a huge amount of directories most of their names contain whitespaces and print the path of the directory if... (8 Replies)
Discussion started by: sumi76
8 Replies

6. Shell Programming and Scripting

Test for a file existence

deleted (1 Reply)
Discussion started by: ust
1 Replies

7. Programming

C function to test existence of a login

Hi everybody, I need to check in C program whether a given login is known on the system. Is there any system function that could do this ? So far, all I could find is getpwnam(), which answers my problem by parsing the local password database. But won't work if a user is authenticated by... (2 Replies)
Discussion started by: xavier054
2 Replies

8. Shell Programming and Scripting

verifying existence of multiple files

Hi, I have unix script on solaris 5.10. I have to verify existence of 3 files in path and sleep for 1 hour. I have tried for 1 file: if then echo " File is found!" sleep 3600 echo "time delayed" fi Please advice (6 Replies)
Discussion started by: ammu
6 Replies

9. Shell Programming and Scripting

check for FILES existence

hi, I have a list of filenames and I want to verify if they all exist. I know "if filename" would do the trick but how do I go about a list of files? thanks (3 Replies)
Discussion started by: mpang_
3 Replies

10. Shell Programming and Scripting

how to test for file existence using file size?

ok im doing this in a normal shell. i need to check the file in the script. how should i write the if else statment? if the filesize contains 0kb then it will echo out file contains nothing else if the script contains more than 0kb then it will echo out file exist. any one care to help?... (3 Replies)
Discussion started by: forevercalz
3 Replies
Login or Register to Ask a Question