1 [root@localhost ~]# cat x.sh 2 #!/bin/bash 3 4 fun_x () { 5 6 du -h $1 |tail -1 7 8 } 9 10 for i in `ls $1` 11 do 12 fun_x $1$i 13 done 14 [root@localhost ~]# sh x.sh /usr/ 15 132M /usr/bin 16 4.0K /usr/etc 17 4.0K /usr/games 18 34M /usr/include 19 325M /usr/lib 20 447M /usr/lib64 21 34M /usr/libexec 22 6.1G /usr/local 23 28M /usr/sbin 24 1.1G /usr/share 25 48M /usr/src 26 0 /usr/tmp 27 [root@localhost ~]#