Compare values from 2 tab seperated files

Watnog used Ask the Experts™
I had this question after viewing Unix AIX compare column of 2 files.

Hi Experts,
I try to make these lines work:

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
echo ""$FileSystem" could not be checked"
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.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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.

Personally, I'd drop the shell script and do everything in a perl script.
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.


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.



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.
Old school. Nothing to be proud of or worth sharing.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial