#!/bin/bash

echo '<<<quotas>>>'

command -v repquota >/dev/null 2>&1
if [ $? == 0 ];then
   case $(repquota -V | head -n 1 | awk '{print $4}') in
      "3.14.")
          quotas=$(repquota -a 2>&1 | awk '{if ((NF == 8) && ($3+0 == $3)) print $1 " " $3 " " $4 " " $5 " " $6 " " $7 " " $8}' )
          res=$?
          ;;
      *)
          quotas=$(repquota -ap 2>&1 | awk '{if ((NF == 10) && ($3+0 == $3)) print $1 " " $3 " " $4 " " $5 " " $7 " " $8 " " $9}' )
          res=$?
          ;;
   esac
fi

if [[ $quotas == "" ]]; then
   cmd_mmrepquota=""   
   for i in "mmrepquota" "/usr/lpp/mmfs/bin/mmrepquota" ; do
       command -v $i >/dev/null 2>&1
       if [ $? == 0 ];then
           cmd_mmrepquota=$i
           break
       fi   
   done

   if [ ${#cmd_mmrepquota} -gt 0 ]; then
      quotas=$($cmd_mmrepquota -a 2>&1 | awk '{if ((NF == 14) && ($3+0 == $3)) print $1 " " $3 " " $4 " " $5 " " $9 " " $10 " " $11}' )
      res=$?   
   fi
fi

if [[ $res == 0 && $quotas != "" ]]; then
   echo "$quotas"
fi 
