Sygnwmh gia ta akatalabistika ..

V13 v13 at priest.com
Wed Jan 8 15:35:01 EET 2003


On Wednesday 08 January 2003 12:46, Giorgos Keramidas wrote:
> On 2003-01-08 10:09, Άγγελος Οικονομόπουλος <aoiko at cc.ece.ntua.gr> wrote:
> > On Tuesday 07 January 2003 19:42, V13 wrote:
> > > On Tuesday 07 January 2003 16:34, Άγγελος Οικονομόπουλος wrote:
> > > Έχεις κάποιο πρόβλημα με το OS/2 ?
> >
> > σίγουρα όχι ο, τι πιό μαγικό έχω κάνει ποτέ, αλλά με μηδενικό
> > redundancy. Γιά να ξεκινήσω την εγκατάσταση, θα πρέπει να πάρω
> > backup απο, χμμ...
> >
> > bash-2.05b$ res=0; for num in `df | awk '{print $3}'`; do \
> > let "res = $res + $num"; done ; echo $res
> > 27976179
> > bash-2.05b$
>
> Bash loops και αηδίες!  Με απογοητεύεις :P
>
> $ df | awk '{sum += $3} END {print sum}'

hell:~$ df -k
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/ide/host0/bus0/target0/lun0/part3
                       1960231   1000895    859733  54% /
none                    193132         0    193132   0% /dev/shm
/dev/ide/host0/bus0/target0/lun0/part10
                        964500    474036    441468  52% /home/dev
/dev/ide/host0/bus0/target0/lun0/part7
                       9843276   8800620    542636  95% /mnt/extra
/dev/ide/host0/bus0/target0/lun0/part5
                       9843276   8026172   1317084  86% /mnt/dl
/dev/ide/host0/bus0/target0/lun0/part8
                       3937220   2740364    996852  74% /tmp2
/dev/ide/host0/bus0/target0/lun0/part11
                       9614116   8678176    447568  96% /mnt/mp3
none                    524288       664    523624   1% /tmp
none                     51200       456     50744   1% /var/log/fast
none                     10240       124     10116   2% /var/run
none                    307200         0    307200   0% /var/tmp
/tmp/aa                7281776   4059644   2852240  59% /mnt/3

Katalabeneis oti stin parapano periptosi den doylevei...
(oxi epidi to $3 ginetai 0 , alla epidi den einai panta to $3 poy theloyme)

Synisto kati se:

df -k | awk '
BEGIN {koko=0; sum=0}
koko==1 {sum+=$2; koko=0}
/^\// && $2=="" {koko=1}
/^\// && $2!="" {sum+=$3}
END {print sum}'

Alla kai pali exei problima me devices ta opoia einai mounted 2 fores, opote 
theloyme kati san to:

df -k | awk '
BEGIN {koko=0; first_line=1}
first_line==1 && /^\// { first_line=0; }
koko==1 {printf("%s %s\n",tmp,$2);koko=0}
/^[^ ]/ && $2=="" && first_line==0 {koko=1; tmp=$1}
/^[^ ]/ && $2!="" && first_line==0 {printf("%s %s\n",$1,$3);}
first_line==1 { first_line=0; }
' | sort -u | (	\
 sum=0; \
 while read a b ; do \
  test -b "$a" && let sum+=$b ; \
 done ; \
 echo "Exeis $sum kb gia backup" )

To opoio prepei na doylevei akoma kai otan to mount exei ginei xoris absolute 
path sto device, asxetos me to an exei h oxi header to output ths df kai 
ypologizei mono ta pragmatika block devices... (bebaia prepei na treksei mesa 
sto to dir sto opoio yparxoyn ta devices ta opoia eginan mount xoris full 
path)

<<V13>>

p.s. Bebaia den doylevei sosta otan kapoio device yparxei me 2 diaforetika 
onomata alla ayto malon ksefeygei arketa...

p.s.2 Tora thymithika kai to 'df -P', opote polla apo ta parapano einai 
axrista :P

p.s.3 Eimai sigoyros oti kapos etsi ksekinise kai to gnuhello



More information about the Linux-greek-users mailing list