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 06-28-2006
SummitElse SummitElse is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 19
comparing files to contents of a file

Hi I have a problem trying to run a while statement.

I have files under one directory that i need to compare to a value in filex and update that file with the result

files in the directory are

DFC1.
DFC5.
DFC345.
DFC344.
DFC9.

The program i am trying to run will take the number form the filename
and compare it to the value in filex

it should run through each value in the directory compare it to the value in filex and if greater then replace the value in filex and remove the filename from the directory

i.e. compare DFC1. the value 1 to the value in filex = 0
it is greater so replace value in filex with 1 delete DFC1. and do next filename DFC5. same for DFC345. and DFC344 (but this one should fail)

any ideas

trying this #! /usr/bin/ksh

cd /swm/test/apps/creditors/temp
pwd

var1=$(ls -t DFC*.)
echo $var1
#while read var1
#do
echo cat $var1
var2=$(echo $var1|cut -d. -f1|cut -c5-)
echo $var2 > /swm/test/apps/creditors/temp/valuex
if
[$var2 -ge var3=$(cat valuex)]
then
rm $var1
else
echo "the current value is greater than the file $var1

thanks for any help