Sponsored Content
Full Discussion: Test existance of a file
Top Forums UNIX for Dummies Questions & Answers Test existance of a file Post 302467134 by siba.s.nayak on Thursday 28th of October 2010 10:30:59 AM
Old 10-28-2010
Test existance of a file

Hi,

I need to find out if a particular file exists and i am using if with -e option.

Scenarion is like

There is a possibility of two files having nomaincluture like below
First file = abc20101028.somthing
Second File = abc20101028.somthing.done

I need to check abc20101028.somthing exists (Somthing is anything except "done")
Code:
tdate=20101028
if [ -e abc*$tdate*]  # it should not check for done file
then
     if [-e abc*$tdate*done]
     then
         continue
     else
         echo "Done file missing"
     fi
else
    echo "Original File missing"
fi

But in the above logic in the first IF condition, it will return true eve if original is missed but "done" file exists. How can I overcome this.

I tried with
Code:
 ls abc*$tdate*[^done]

but no luck.....
Thank you....
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File existance

Guys Iam trying to do a script to find what files are missing in particular directory.I came up with this for i in file6 file7 file8 file9 file10 file11 file12; do if ; then echo " $file not in /mnt/Server/base/i386/ " else echo " $file ... " fi done Iam trying to print... (2 Replies)
Discussion started by: coolkid
2 Replies

2. UNIX for Dummies Questions & Answers

Checking file existance by extension

I'm sure this can't be too tough, but. I want to check the existance of file(s) by extension. There may be 0,1,N files. If any files exist, then remove them. Thanks for any insight. (3 Replies)
Discussion started by: niswonp
3 Replies

3. Shell Programming and Scripting

check the file existance

Hello, I have two files .. 1. inventory_i.txt 2. inventory_b.txt I want to check if these two files exists. If exists, then do the process, otherwise, quite... if ; then echo "exists" else echo " does not exists" fi The above logic is not working... It is always, displaying Does... (2 Replies)
Discussion started by: govindts
2 Replies

4. UNIX for Advanced & Expert Users

speed test +20,000 file existance checks too slow

Need to make a very fast file existence checker. Passing in 20-50K num of files In the code below ${file} is a file with a listing of +20,000 files. test_speed is the script. I am commenting out the results of <time test_speed try>. The normal "test -f" is much much too slow when a system... (2 Replies)
Discussion started by: nullwhat
2 Replies

5. Shell Programming and Scripting

Test File Existance Remotely?

Thanks in advance to anyone that can help me answer this: I'm trying to write an if statement that will run test -f on whether a file exists on another server and if it does not then report that negative outcome to a log file. I'm thinking it should look something like this: if ; then rcp... (5 Replies)
Discussion started by: Korn0474
5 Replies

6. Shell Programming and Scripting

Scripting to check the size of file and it's existance.

Hi, I am totaly new to create a script . Please help. I have file name retrived from SAP table into a internal table . Like :- /home/td_8d02_int_data_IPCL/ILLUSTRATIONS/CGM/l_pc_112138_01_0_01_00.cgm /home/td_8d02_int_data_IPC-L/ILLUSTRATIONS/CMP/l_pc_112138_01_0_01_00.cmp Objective... (1 Reply)
Discussion started by: amitkumar.b2
1 Replies

7. Shell Programming and Scripting

[Solved] Know the existance of a file on remote server

In a Korn shell, I want to test whether a file exists on a remote shell. If I use ssh <Remote server> ls abc It gives file proper result, but unable to capture in the script. Any help? Thanks Please use next time code tags for your code and data (3 Replies)
Discussion started by: Soham
3 Replies

8. Shell Programming and Scripting

Error while checking file existance

Kindly help on below script: << i='find ...' if then echo 'File Exists' else echo 'File Does Not Exist' >> If i has some file name then it runs properly but if i has nothing ( blank value) then it throws an error. I dont exactly remember right now but error seems like:... (2 Replies)
Discussion started by: ravigupta2u
2 Replies

9. Shell Programming and Scripting

Csh/tcsh : Check the file existance and run the script

Hi, I've to wait until a file generated and once its generated, source another script in Linux terminal. Please help me as this is very very urgent. The code should be something like if ( -e "/abc/xyz/a.txt ) source aaa.csh else sleep This should be repeated till the if... (4 Replies)
Discussion started by: kumar_eee
4 Replies

10. Shell Programming and Scripting

Checking Multiple File existance in a UNIX folder(Note: File names are all different)

HI Guys, I have some 8 files with different name and extensions. I need to check if they are present in a specific folder or not and also want that script to show me which all are not present. I can write if condition for each file but from a developer perspective , i feel that is not a good... (3 Replies)
Discussion started by: shankarpanda003
3 Replies
Test::ClassAPI(3pm)					User Contributed Perl Documentation				       Test::ClassAPI(3pm)

NAME
Test::ClassAPI - Provides basic first-pass API testing for large class trees DESCRIPTION
For many APIs with large numbers of classes, it can be very useful to be able to do a quick once-over to make sure that classes, methods, and inheritance is correct, before doing more comprehensive testing. This module aims to provide such a capability. Using Test::ClassAPI Test::ClassAPI is used with a fairly standard looking test script, with the API description contained in a __DATA__ section at the end of the script. #!/usr/bin/perl # Test the API for Foo::Bar use strict; use Test::More 'tests' => 123; # Optional use Test::ClassAPI; # Load the API to test use Foo::Bar; # Execute the tests Test::ClassAPI->execute; __DATA__ Foo::Bar::Thing=interface Foo::Bar::Object=abstract Foo::Bar::Planet=class [Foo::Bar::Thing] foo=method [Foo::Bar::Object] bar=method whatsit=method [Foo::Bar::Planet] Foo::Bar::Object=isa Foo::Bar::Thing=isa blow_up=method freeze=method thaw=method Looking at the test script, the code itself is fairly simple. We first load Test::More and Test::ClassAPI. The loading and specification of a test plan is optional, Test::ClassAPI will provide a plan automatically if needed. This is followed by a compulsory __DATA__ section, containing the API description. This description is in provided in the general form of a Windows style .ini file and is structured as follows. Class Manifest At the beginning of the file, in the root section of the config file, is a list of entries where the key represents a class name, and the value is one of either 'class', 'abstract', or 'interface'. The 'class' entry indicates a fully fledged class. That is, the class is tested to ensure it has been loaded, and the existance of every method listed in the section ( and its superclasses ) is tested for. The 'abstract' entry indicates an abstract class, one which is part of our class tree, and needs to exist, but is never instantiated directly, and thus does not have to itself implement all of the methods listed for it. Generally, many individual 'class' entries will inherit from an 'abstract', and thus a method listed in the abstract's section will be tested for in all the subclasses of it. The 'interface' entry indicates an external interface that is not part of our class tree, but is inherited from by one or more of our classes, and thus the methods listed in the interface's section are tested for in all the classes that inherit from it. For example, if a class inherits from, and implements, the File::Handle interface, a "File::Handle=interface" entry could be added, with the "[File::Handle]" section listing all the methods in File::Handle that our class tree actually cares about. No tests, for class or method existance, are done on the interface itself. Class Sections Every class listed in the class manifest MUST have an individual section, indicated by "[Class::Name]" and containing a set of entries where the key is the name of something to test, and the value is the type of test for it. The 'isa' test checks inheritance, to make sure that the class the section is for is (by some path) a sub-class of something else. This does not have to be an immediate sub-class. Any class refered to (recursively) in a 'isa' test will have its 'method' test entries applied to the class as well. The 'method' test is a simple method existance test, using "UNIVERSAL::can" to make sure that the method exists in the class. METHODS
execute The "Test::ClassAPI" has a single method, "execute" which is used to start the testing process. It accepts a single option argument, 'complete', which indicates to the testing process that the API listed should be considered a complete list of the entire API. This enables an additional test for each class to ensure that every public method in the class is detailed in the API description, and that nothing has been "missed". SUPPORT
Bugs should be submitted via the CPAN bug tracker, located at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-ClassAPI <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-ClassAPI> For other issues, or commercial enhancement or support, contact the author. AUTHOR
Adam Kennedy <adamk@cpan.org> COPYRIGHT
Copyright 2002 - 2009 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.14.2 2009-07-13 Test::ClassAPI(3pm)
All times are GMT -4. The time now is 09:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy