Hi guys,
Do you have any idea how to minimise my script :
I'm sure It could be minimised, but I don't have a clue yet.
Thx Guys
Do you have any idea how to minimise my script :
Code:
#!/bin/ksh
if [ "$#" != "2" ]
then
echo "usage : sumdisc [data from which vendor "airbus" or "boeing"] [path directory]"
exit 1
fi
if [$1 = "airbus"]
then
cd $2
du -sk */* | awk '{
if ($2 ~ /SGML/){
sum += $1
print $0
}
if (($2 ~ /TIFF/)||($2 ~ /CGM/)){
jumlah +=$1
a[i++]=$0
}
}
END {
total = 30*sum
semua = total + jumlah
printf "TOTAL SGML FILES IS = %s \n SPACE FOR SGML : 30 * %s = %s \n\n", sum, sum, total
for(j=0;j<i;++j)print a[j]
printf "TOTAL GRAPHIC FILES = %s \n TOTAL SPACE REQUIRED = %s \n", jumlah, semua
}'
fi
if [$1 = "boeing"]
then
cd $2
du -sk */* | awk '{
if ($2 ~ /SGML/){
sum += $1
print $0
}
if (($2 ~ /TIFF/)||($2 ~ /CGM/)){
jumlah +=$1
a[i++]=$0
}
}
END {
total = 6*sum
semua = total + jumlah
printf "TOTAL SGML FILES IS = %s \n SPACE FOR SGML : 6 * %s = %s \n\n", sum, sum, total
for(j=0;j<i;++j)print a[j]
printf "TOTAL GRAPHIC FILES = %s \n TOTAL SPACE REQUIRED = %s \n", jumlah, semua
}'
fi
I'm sure It could be minimised, but I don't have a clue yet.
Thx Guys