码迷,mamicode.com
首页 > 系统相关 > 详细

shell中遍历目录

时间:2015-06-24 16:44:15      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:shell

比如在/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中遍历目录

标签:shell

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!