Question

I'm trying to compare tablespaces sizes between 2 databases. I already extracted the needed field to compare as above:

STAT-TBS-DB-SOURCE.lst: (column 1 : TBS Name, column 2 : real size)

TBS001 12
TBS002 50
TBS003 20
TBS004 45

STAT-TBS-DBTARGET.lst (column1:TBS Name, column 2 :max size)

TBS001 10
TBS002 50
TBS003 20
TBS004 40

I need to compare the second columns (c1,c2) of the 2 files (f1,f2), if f2.c2<f1.c2 then print increase Tablespace f1.c1 by ( f1.c2 - f2.c2) MB.

What solution have you for me?

I tried with awk but I cannot get the value of the f1.c2.

Thanks

Was it helpful?

Solution

kent$  awk 'NR==FNR{a[$1]=$2;next}$1 in a && $2<a[$1]{
       printf "increase Tablespace %s by %d MB\n",$1,(a[$1]-$2)}' f f2 
increase Tablespace TBS001 by 2 MB
increase Tablespace TBS004 by 5 MB
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top