0

I have this script

table="COLECTOR.COLECTOR.GPRS_SUM_REP"

tab_array=(${table//./ })
database="${tab_array[0]}"
schema="${tab_array[1]}"
tablename="${tab_array[2]}"

skew=$(/nz/support-IBM_Netezza-11.2.1.1-210825-0050/bin/nz_record_skew $table)
rskew=$(echo "$skew" | grep $tablename | awk 'BEGIN { FS="|" } { split($7,a,"-"); gsub(/ /, "", a[2]); print a[2] }')

echo "$skew"
echo $rskew

if [[ $rskew -gt 1 ]]; then
  echo "is greater than 1";
else
  echo "is less than 1";
fi;

I have this error

Database: COLECTOR                                 (Sorted by Table Name)

 Table                           | # DSlice's |       Row Count      |    Min # Rows    |    Avg # Rows    |    Max # Rows    |   SKEW RATIO
---------------------------------+------------+----------------------+------------------+------------------+------------------+----------------
 GPRS_SUM_REP                    |        576 |           56,023,104 |           95,901 |           97,262 |           98,491 | 0.986 -    1.013
1.013
ratio.sh: line 15: [[: 1.013: syntax error: invalid arithmetic operator (error token is ".013")
is less than 1

I am trying to compare 1.013 -gt 1 but got error

What can I do to make the comparison?

  • You'll want to factor both the [useless `grep`](https://www.iki.fi/era/unix/award.html#grep) and the float comparison into the Awk script. – tripleee Aug 18 '22 at 04:26
  • `-gt` is doing integer comparision. Use something like `bc` or `awk` or `Perl`, or use zsh, which has float arithmetic `if ((rskew > 1))`... And, please, remove the `sh` tag from your question. _sh_ means Unix Bourne shell. – user1934428 Aug 18 '22 at 06:00

0 Answers0