Shell Presentation taille FS

#!/bin/ksh
#================== Table Colonnes pour l edition commande df

set -a

Edit_Zones="\
edtfs;Filesystem;17\
edtblock;blocks;15\
edtfre;Free;15\
edtused;%Used;7\
edtiused;Iused;12\
edtpiused;%Iused;7\
edtmnt;Mounted_on;45"

Souli=";=;$( $COMMUN/outils/Edit_Tableau.exe longl ${Edit_Zones} )"

#======== Fonction Edit
#    $COMMUN/outils/Edit_Tableau.exe souli ${Souli}
#    $COMMUN/outils/Edit_Tableau.exe titre ${Edit_Zones}
#    $COMMUN/outils/Edit_Tableau.exe souli ${Souli}

i=0
typeset -R edtused
typeset -R edtpiused

test $# -eq 0 && taux=0 || taux=$1
test $# -eq 2 && taille=$2 || taille=k


df -$taille | while read edtfs edtblock edtfre edtused edtiused edtpiused edtmnt
do

 if test $i -eq 0
 then
    $COMMUN/outils/Edit_Tableau.exe souli ${Souli}
    $COMMUN/outils/Edit_Tableau.exe ligne ${Edit_Zones}
    $COMMUN/outils/Edit_Tableau.exe souli ${Souli}
 else
    ptaux=$( echo $edtused | sed "s/%//;s/\-/0/g" )
    if test $ptaux -ge $taux
    then
         $COMMUN/outils/Edit_Tableau.exe ligne ${Edit_Zones}
    fi
 fi

 (( i+=1 ))

done

   $COMMUN/outils/Edit_Tableau.exe souli ${Souli}
echo "\nDonner un nombre en parametre et vous aurez les FS ayant un taux d occupation >= a ce nombre \n"

exit

#------------------ meme avec awk

typeset -l taille

test $# -eq 0 && taux=0 || taux=$1
test $# -eq 2 && taille=$2 || taille=k

#echo "Filesystem    1024-blocks      Free %Used    Iused %Iused Mounted on"

echo "\n========================================================================================================================================="
if test "$taille" = "k"
then
echo "    Filesystem        |1024-blocks |     Free   |   %Used    |   Iused    |   %Iused   |   Mounted on "
else
echo "    Filesystem        | Taille Go  |     Free   |   %Used    |   Iused    |   %Iused   |   Mounted on "
fi
echo "========================================================================================================================================="

df -${taille} | awk '
BEGIN {
 taux="'$taux'" ;
}
{ x=index($4,"%"); y=substr($4,1,x-1); if ( y >= taux ) { z=sprintf(" %-20s | %10s | %10s | %10s | %10s | %10s | %-10s ", $1, $2, $3, $4, $5, $6, $7 );print z }}'

echo "========================================================================================================================================="

Previous page: Create New Lv Fs
Page suivante : SMIT_Doc