Compare values from 2 tab seperated files

I had this question after viewing Unix AIX compare column of 2 files.

Hi Experts,
I try to make these lines work:

#!/bin/ksh
file1=file1.txt
file2=file2.txt
while read LINE ; do
FileSystem=`echo $LINE | awk '{print $3}'`
GrowthTreshold=`echo $LINE | awk '{print $5}'`
if [ "$GrowthTreshold" -ge 0 ] 2>/dev/null  ; then
echo $GrowthTreshold
perl -ane '$k=$F[0].$F[2]; print if exists($h{$k}) && $F[3]-$h{$k}>='$GrowthTreshold'; $h{$k}=$F[3]' $file1 $file2 >>ExceptionList.txt
else
echo ""$FileSystem" could not be checked"
fi
done <$file1.txt

###

I attach a file1.txt and a file2.txt

Values of file2.txt are compared to those of file1.txt
In this example:
- the first line is one that should be logged: 78 to 88 = 10 so that exceeds the allowed growth treshold of 5
- and also the last line: 34 to 40 = 6 so that exceeds of the allowed growth treshold of 5

When I run the script as it is now this is returned:

...
syntax error at -e line 1, near ">=;"
Execution of -e aborted due to compilation errors.


Thank you for your help.
Watnog
file1.txt
file2.txt
WatnogAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

FishMongerCommented:
Looks like you have a quoting issue with your one-liner.

Remove the single quotes around the $GrowthTreshold var.  If quotes are really needed by the shell, then use double quotes around that var.

EDIT:
Personally, I'd drop the shell script and do everything in a perl script.
0
FishMongerCommented:
In case it's not clear why I said to change the quotes, that first single quote around the $GrowthTreshold var is terminating the one-liner leaving it incomplete and giving the error.
0
WatnogAuthor Commented:
Thanks FishMonger, as EE is my last resort, I did play with the quotes as I know that's tricky.
Anyway, copying the quotes from a place where the same line does work did the trick (reading the var), I have no explanation for that.

I have another problem, the perl line if it finds a match prints the entire file, it should only print the matching line.
If you'd have some more time to check into I'd be very grateful.
If you have a better solution altogether, that's fine too of course.

Watnog
0
WatnogAuthor Commented:
Well, I hope I don't hurt your feelings, but I kind of regressed, dropped the perl line and have it done shell-wise.
One of the advantages is that at least I understand (better) what and how things are done.

This means you are free.
Thanks very much all the same. it's great to know there's an expert in case you'd get completely lost.
0
WatnogAuthor Commented:
Old school. Nothing to be proud of or worth sharing.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.