Find Set of files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find Set of files
# 1  
Old 06-29-2011
Find Set of files

All,

I am trying to find a set of files, it could be one file OR set of file ,
all with extension .DAT
I need to do some acticity, only if the files exist in a partificular folder
like

Code:
if [ ! -f $Landing/*.DAT ]; then
                CntV=`ls $Landing/*.DAT |wc -l`
                echo "Lst Value " $Cnt
               if [ $CntV -lt 1 ]; then
                        echo No Landing Files in  $LandingZP
                         exit ....

I still get the unix error for the files not found ,
Code:
*.DAT: No such file or directory

can someone pls tell me , what's wrong in the code or Approach ?

Thanks
-

Last edited by radoulov; 06-30-2011 at 11:32 AM.. Reason: Code tags.
# 2  
Old 06-29-2011
Quote:
Originally Posted by Shanks
if [ ! -f $Landing/*.DAT ]; then
Then test for the presence of .DAT files instead of negating the test...
Code:
 if [ -f $Landing/*.DAT ]

# 3  
Old 06-30-2011
Code:
ls $Landing/*.DAT >/dev/null 2>&1

if [ $? -eq 0 ]
then 
  echo yes
fi

# 4  
Old 06-30-2011
Code:
set -- "$Landing"/*.DAT
[ -f "$1" ] &&
  printf 'number of .DAT files in %s: %d\n' "$Landing" $# ||
    printf 'no .DAT files in %s\n' "$Landing"

The set -- part will reset your positional parameters.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help needed with shell script to search and replace a set of strings among the set of files

Hi, I am looking for a shell script which serves the below purpose. Please find below the algorithm for the same and any help on this would be highly appreciated. 1)set of strings need to be replaced among set of files(directory may contain different types of files) 2)It should search for... (10 Replies)
Discussion started by: Amulya
10 Replies

2. UNIX for Advanced & Expert Users

Find the list of files with a set of Users

Hello all, I want to find the files for certain users. I cant make the or condition work in this instance. I've tried the code below but it didnt worked. Any input on how to get the list for all files for this users. find . -type f -user abc134 -o -user xyz345 -o bce483 -exec ls... (6 Replies)
Discussion started by: sethmj
6 Replies

3. UNIX for Dummies Questions & Answers

Find a set of files in a location

Hi, I am new to Unix. I need a script to check some 74 files are present in a particular location or not . (4 Replies)
Discussion started by: nid21
4 Replies

4. UNIX for Dummies Questions & Answers

Can't find where alias is set

I have an alias set on linux: progs -> /home/user01/prog1.pl the location of prog is changes to /home/user01/new/prog1.pl so I need to modify alias, except I can not find where it is set. It is not in .bashrc or .profile, it is visible by "alias" command. Sorry if it is trivial. (4 Replies)
Discussion started by: analyst
4 Replies

5. Shell Programming and Scripting

Finding compound words from a set of files from another set of files

Hi All, I am completely stuck here. I have a set of files (with names A.txt, B.txt until L.txt) which contain words like these: computer random access memory computer networking mouse terminal windows All the files from A.txt to L.txt have the same format i.e. complete words in... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

6. Shell Programming and Scripting

To find latest set of logs among new and old

Hi All I am writing a script which will select the latest logs (which are generated every night via a script) among old one and new. Script generates set of 3 logs each time it runs. Example : log-WedJun082011_bkt1.log log-WedJun082011_bkt2.log log-WedJun082011_bkt3.log I have... (1 Reply)
Discussion started by: ratneshnagori
1 Replies

7. Programming

SQL: find if a set od dates falls in another set of dates

Don't know if it is important: Debian Linux / MySQL 5.1 I have a table: media_id int(8) group_id int(8) type_id int(8) expiration date start date cust_id int(8) num_runs int(8) preferred_time int(8) edit_date timestamp ON UPDATE CURRENT_TIMESTAMP id... (0 Replies)
Discussion started by: vertical98
0 Replies

8. Shell Programming and Scripting

Find max number in a set

Is there a simple way of calculating the max number in a set of variables, so a=1 b=3 c=6 d=30 something that says e=max($a, $b, $c, $d) I've found a way to do it using: a="1" b="3" c="5" d="50" if ; then t=$a else (3 Replies)
Discussion started by: unclecameron
3 Replies

9. UNIX for Dummies Questions & Answers

PATH set but I can't find where!!!!

Hi, Can anybody help with this? When I log into my user account on my box via ssh and then instantly perform an env command I see that my path has been set as follows: PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin My user account uses the ksh shell. In my home directory there is no... (7 Replies)
Discussion started by: Donkey25
7 Replies
Login or Register to Ask a Question