[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 ~]$