Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching One Dir using the FOR or the IF statement. 1

Status
Not open for further replies.

tijerina

Vendor
Mar 4, 2003
132
US
Hello,

Can some one please help me? I am stuck on how to search one directory on a machine, the search against this one dir, will match what is in a static file. If a file does not match from a single dir with the static file, then a print or echo will be issued. I am not sure how to use my for statement with my while read statement. The goal is to create a menu and when the a product needs to be searched to see if the files are present, we will then press the appropirate menu number and the script below will run when chosen from a menu.



Here is what I have so far.

#!bin/ksh

SERVER=`uname -n`

FILELIST=/DJ/PUB/REGOLIST

while read -r xx
do
if [ ! -f $dir/$xx ] ;then
print "File Missing:$dir/$xx- On Machine:${SERVER}"
fi
done < ${FILELIST}
done
 
Where is &quot;dir&quot; being set? What should &quot;dir&quot; be set too?

If we assume you are setting &quot;dir&quot; somehow:

for xx in `cat $FILELIST`
do
if [ ! -f $dir/$$xx ]
then
print &quot;File Missing:$dir/$xx- On Machine:${SERVER}&quot;
fi
done
 
Thank you for your help and the catch on the DIR path.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top