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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to compare between files

Status
Not open for further replies.

Dudek

Technical User
Jan 14, 2002
27
MY
Hi there.. I was wondering whether anyone can help me here..

I have ten files which is divided into two groups IN and OUT

the format of the files are

rraIN, rraOUT, rrkIN, rrkOUT, szrIN, szrOUT.....

where the first 3 letters are in a list in another file list.txt which lists

rra
rrk
szr
....etc etc

so basically what i need to do is..

for(each entry in list.txt)
{
if (IN file != OUT file)
{set $variable = 99}
}
# basically it needs to check whether both IN and OUT
# file are identical and if it doesnt set it to 99, run
# another script (success)
if ($variable !=99)
{
run another script
}


so what i need to know is whether the first part is possible or not, can anybody help me on this..?

TIA

JD
 
Suggest you use diff and check the exit status ($?). If it's 0, the files are identical, if not, they aren't. HTH.
 
this korn shell script should give you a start:

#!/usr/bin/ksh

for f in $( < list.txt)
do
[tab]print &quot;checking ${f}IN against ${f}OUT&quot;
[tab]ret_val=$?
[tab]if [[ $ret_val -ne 0 ]]
[tab]then
[tab][tab]print &quot; ${f}IN and ${f}OUT differ&quot;
[tab]fi
done Mike
&quot;Experience is the comb that Nature gives us after we are bald.&quot;

Is that a haiku?
I never could get the hang
of writing those things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top