The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 04-23-2009
tonydsam tonydsam is offline
Registered User
  
 

Join Date: May 2004
Posts: 17
Check file exists from a shellscript

Hi,

I have a list of files that I want to check to see if they exist and then count how many of these files exist, I also want to do the same for the files that arent found.

I have done this by creating temp files see below but want ot do this using variables instead:


Code:
for FILE in $FILELIST
do
ls -l $OKAYDIR/$FILE >>countload.txt 2>/dev/null
done

LOADCOUNT=`cat countload.txt|wc -l`
cat countload.txt >>results.txt

echo >>results.txt
echo "$LOADCOUNT files loaded">>results.txt

Thanks.