[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
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
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 ~]$
user 0m0.002s
sys 0m0.009s
[jeff@rhel55 ~]$
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27795363/viewspace-747159/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/27795363/viewspace-747159/