1 #!/bin/bash
 2 ##############################################
 3 #Author:rubyzhu
 4 #Date:2013.1.29
 5 #Version:1.0
 6 #Update:2013.1.30
 7 #Description: Back up your files
 8 ##############################################
 9 
10 #shell Variable
11 path_source=/mnt/fifth/shell
12 path_backup=/mnt/fifth/backup/shellbackup
13 path_delete=/mnt/fifth/tmp/rubbish/
14 limit_num=15
15 
16 fileBackup()
17 {
18 set -x
19 #back up
20 #cp -r $1 $2/shell-`date +%Y-%m-%d-%H-%M-%S`
21 count=`ls $1 | wc -w`
22 
23 if [ "$count" -gt "$3" ];then
24     echo "-----------------limit is : $3 ----------------------"
25     echo "-----------------The number of files is : $count -------"
26     num=`expr $count - $3`
27     echo "-----------------The excess number of files is : $num ---------"
28 #move
29     ls $1 -1rt | head -n $num|xargs -n1 -i mv $1/{} $2
30     set +x
31     ls -1rt $2
32     echo "-----------------Moving end!-----------------"
33 else
34     ls -1rt $2
35     echo "-----------------The file is too little!-------------------"
36 fi
37 
38 }
39 
40 #back up shell
41 fileBackup $path_backup $path_delete $limit_num

相关文章:

  • 2022-01-24
  • 2021-12-08
  • 2021-05-21
  • 2021-07-14
  • 2021-09-06
  • 2021-12-03
  • 2021-08-09
  • 2021-08-31
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
  • 2022-12-23
  • 2021-12-02
相关资源
相似解决方案