zoukankan      html  css  js  c++  java
  • shell-保留文件系统下剩余指定数目的文件

     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
  • 相关阅读:
    H5 后代选择器
    H5 id选择器和class选择器
    H5 类选择器
    H5 id选择器
    H5 标签选择器
    H5 颜色属性
    H5 文本属性
    H5 文字属性的缩写
    H5 字体属性补充
    H5 文字属性
  • 原文地址:https://www.cnblogs.com/zhuhongbao/p/3402395.html
Copyright © 2011-2022 走看看