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

linux获取目录下文件

时间:2014-07-22 23:09:14      阅读:407      评论:0      收藏:0      [点我收藏+]

标签:style   color   文件   io   for   re   

查看当前目录下的文件:
find . -type f

查看当前目录下的文件夹:
find . -type d

如果文件file1不为空:
if [ -s file1 ];then
      echo "file1 不为空"
fi

#!/bin/sh
for in `find ./testdir -type f`;
do
        if -s $f ];then
                echo $f is not empty.
                echo copy $f
                cp $f ~/backup
        else
                echo $f is empty.
        fi
done
 
 
 
#!/bin/bash
find /etc -type f > list.txt
while read line; do
    size=$(ls -l $line | awk ‘{print $5}‘)
    if [[ $size != 0 ]]; then
        cp $line /tmp/
    fi
done < list.txt

linux获取目录下文件,码迷,mamicode.com

linux获取目录下文件

标签:style   color   文件   io   for   re   

原文地址:http://www.cnblogs.com/zmlctt/p/3700265.html

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