ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 查找文件并移动

查找文件并移动

原创 Linux操作系统 作者:diggger 时间:2012-10-25 08:49:48 0 删除 编辑
[jeff@rhel55 ~]$ vim findmove.sh 
  1 #!/bin/bash
  2 # find some file that more than 10MB
  3 # and move to /tmp
  4 
  5 SDIR=$1
  6 SIZE=$2
  7 DDIR=$3
  8 
  9 
 10 if [ $# = 0 -o $# = 1 -o $# = 2 ]
 11 then
 12   echo "Usage: `basename $0` "
 13   echo "  where size is: n[cwbkMG]"
 14   echo "Example: `basename $0` /home 10M /opt"
 15 else
 16   for file in $(find $SDIR -size +$SIZE)
 17   do
 18     echo "file is: $(basename $file)"
 19     echo "move $file to $DDIR"
 20     mv $file $DDIR
 21   done
 22   echo "done"
 23 fi
 24 exit 0
[jeff@rhel55 ~]$
[jeff@rhel55 ~]$ time /home/jeff/findmove.sh /home/jeff/ 10M /home/jeff/mydir/
file is: myfile
move /home/jeff/myfile to /home/jeff/mydir/
file is: myfile2
move /home/jeff/myfile2 to /home/jeff/mydir/
done
real 0m0.012s
user 0m0.002s
sys 0m0.009s
[jeff@rhel55 ~]$

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27795363/viewspace-747159/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: I/O重定向详解
请登录后发表评论 登录
全部评论

注册时间:2012-09-13

  • 博文量
    33
  • 访问量
    45476