The UNIX and Linux Forums  


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



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How can i prepare a file by comparing two other files? manmohanpv Shell Programming and Scripting 3 02-18-2008 04:58 AM
Comparing contents of files rrs Shell Programming and Scripting 3 04-03-2007 09:08 PM
comparing shadow files with real files terrym UNIX for Advanced & Expert Users 4 02-09-2007 02:38 AM
Creating file contents using contents of another file ReV Shell Programming and Scripting 21 02-24-2006 10:25 AM
shell script comparing files in a file raina_nalin Shell Programming and Scripting 4 06-21-2005 07:00 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0