Sponsored Content
Full Discussion: Verify if filename exists
Top Forums Shell Programming and Scripting Verify if filename exists Post 302981445 by pointers1234 on Tuesday 13th of September 2016 07:40:18 AM
Old 09-13-2016
Verify if filename exists

Hi,

I have a variable returned from Oracle SQL Function which holds file names.

I would like to test if all the file names mentioned in the string exists in a directory. If all the files exists print "exists", even if one file does not exists print "Does not exists".

e.g.
Code:
 l_FILENAMES="file1 file2 file3 file4"


Regards,
Pointers

Last edited by rbatte1; 09-13-2016 at 09:36 AM.. Reason: Add CODE tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

test if a filename exists with specified string (ksh)

I'm trying to do a simple if statement that tests if a filename exists with a user specified string. So say I have these files: Assigned_1day_after_due_chuong Assigned_1day_after_due_gallen Assigned_1day_after_due_heidenre and i'm running a script and want to know if a... (6 Replies)
Discussion started by: bob122480
6 Replies

2. Shell Programming and Scripting

verify if a process exists (ps)

hi I want to verify that a process exists. if the process exists, then it means the service is up. ps -ef | grep monito returns an entry if the service is up. how to translate that in a shell script?? many thanks (4 Replies)
Discussion started by: melanie_pfefer
4 Replies

3. Shell Programming and Scripting

gzcat into awk and then change FILENAME and process new FILENAME

I am trying to write a script that prompts users for date and time, then process the gzip file into awk. During the ksh part of the script another file is created and needs to be processed with a different set of pattern matches then I need to combine the two in the end. I'm stuck at the part... (6 Replies)
Discussion started by: timj123
6 Replies

4. Shell Programming and Scripting

Filename from splitting files to have the same filename of the original file with counter value

Hi all, I have a list of xml file. I need to split the files to a different files when see the <ko> tag. The list of filename are B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml ... (3 Replies)
Discussion started by: natalie23
3 Replies

5. AIX

verify command

Guy's I have script doing many steps as the below ... ############# ## step1# mount all Files system mount all ## step2# Start the application /app/appsh ############# but some time mount points will not be mounted completely so that will give an error if the next step started... (1 Reply)
Discussion started by: Mr.AIX
1 Replies

6. Shell Programming and Scripting

Verify File exists and execute command

Hi, I am trying to verify that a file exists within an alternate directory. If the file exists, it will execute a copy command...if it does not, it should exit the script. I tried the <test> command and the but keep coming up with syntax errors. I am coding in C Shell and the file... (5 Replies)
Discussion started by: CKT_newbie88
5 Replies

7. Shell Programming and Scripting

File exists, but cannot be opened.How to check- whether it could be opened to read when it exists

Hi #Testing for file existence if ; then echo 'SCHOOL data is available for processing' else echo 'SCHOOL DATA IS NOT AVAILABLE FOR PROCESSING' : i wrote a script, where it begins by checking if file exists or not. If it exists, it truncates the database... (2 Replies)
Discussion started by: rxg
2 Replies

8. UNIX for Dummies Questions & Answers

to extract all the part of the filename before a particular word in the filename

Hi All, Thanks in Advance I am working on a shell script. I need some assistance. My Requirement: 1) There are some set of files in a directory like given below OTP_UFSC_20120530000000_acc.csv OTP_UFSC_20120530000000_faf.csv OTP_UFSC_20120530000000_prom.csv... (0 Replies)
Discussion started by: aealexanderraj
0 Replies

9. Programming

to extract all the part of the filename before a particular word in the filename

Hi All, Thanks in Advance I am working on a shell script. I need some assistance. My code: if then set "subscriber" "promplan" "mapping" "dedicatedaccount" "faflistSub" "faflistAcc" "accumulator"\ "pam_account"; for i in 1 2 3 4 5 6 7 8;... (0 Replies)
Discussion started by: aealexanderraj
0 Replies

10. Emergency UNIX and Linux Support

Waiting for wildcard filename to exists in while loop

Hi Experts, We are developing a script which will wait for the trigger file(with datetime in the trigger file name). But the problem is when I use 'while' loop to wait for the file, it waits for the filename with wilcard in it that is wait for 'Trigger*.done' file. :eek: Below is the script ... (4 Replies)
Discussion started by: Amey Joshi
4 Replies
FILE_EXISTS(3)								 1							    FILE_EXISTS(3)

file_exists - Checks whether a file or directory exists

SYNOPSIS
bool file_exists (string $filename) DESCRIPTION
Checks whether a file or directory exists. PARAMETERS
o $filename - Path to the file or directory. On windows, use //computername/share/filename or \computernamesharefilename to check files on network shares. RETURN VALUES
Returns TRUE if the file or directory specified by $filename exists; FALSE otherwise. Note This function will return FALSE for symlinks pointing to non-existing files. Warning This function returns FALSE for files inaccessible due to safe mode restrictions. However these files still can be included if they are located in safe_mode_include_dir. Note The check is done using the real UID/GID instead of the effective one. Note Because PHP's integer type is signed and many platforms use 32bit integers, some filesystem functions may return unexpected results for files which are larger than 2GB. EXAMPLES
Example #1 Testing whether a file exists <?php $filename = '/path/to/foo.txt'; if (file_exists($filename)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; } ?> ERRORS
/EXCEPTIONS Upon failure, an E_WARNING is emitted. NOTES
Note The results of this function are cached. See clearstatcache(3) for more details. Tip As of PHP 5.0.0, this function can also be used with some URL wrappers. Refer to "Supported Protocols and Wrappers" to determine which wrappers support stat(3) family of functionality. SEE ALSO
is_readable(3), is_writable(3), is_file(3), file(3). PHP Documentation Group FILE_EXISTS(3)
All times are GMT -4. The time now is 11:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy