查看该目录下有几个文件夹几个文件的shell代码

2310阅读 0评论2011-10-24 
分类:Python/Ruby

  1. #!/bin/sh
  2. directory()
  3. {
  4. let "filenum = 0 "
  5. let "dirnum = 0 "
  6. ls $1
  7. echo ""
  8. for dir in $( ls )
  9. do
  10. if [ -d $dir ]
  11. then
  12. let "dirnum+=1"
  13. else
  14. let "filenum+=1"
  15. fi
  16. done
  17. echo "The number of directories is $dirnum "
  18. echo "The number of files is $filenum "
  19. }
  20. directory
上一篇:Shell调试技术总结(二)
下一篇:Linux中sort命令详解