首页 > 系统服务 > 详细

shell中遍历目录

时间:2015-06-24 16:43:59      阅读:186      评论:0      收藏:0      [点我收藏+]

比如在/tmp中有1,2,3,4,5个文件夹

      [root@test tmp]# mkdir {1..5}

      [root@test tmp]# ls

      1  2  3  4  5  test  yum.log

然后在1,2,3,4,5里面有一个同名的文件,比如abc.txt

  遍历脚本如下:

         for dir in `ls /tmp`

        do 

           if [ -d $dir ] 

           then

              动作

           fi  

         done  

本文出自 “rickchen1979” 博客,请务必保留此出处http://richchen1979.blog.51cto.com/8779901/1664967

shell中遍历目录

原文:http://richchen1979.blog.51cto.com/8779901/1664967

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!