欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

linux下保留文件系統(tǒng)下剩余指定數(shù)目文件的shell腳本

 更新時間:2013年11月20日 18:51:46   作者:  
本文介紹下,用于保留文件系統(tǒng)下剩余指定數(shù)量的文件的一個shell腳本,感興趣的朋友可以參考下

本節(jié)內(nèi)容:
保留文件系統(tǒng)下剩余指定數(shù)目的文件

例子:

復(fù)制代碼 代碼如下:

#!/bin/bash
#-------------------------------
#Description: Back up your files
#site: www.dbjr.com.cn
#-------------------------------

#shell 變量
path_source=/mnt/fifth/shell
path_backup=/mnt/fifth/backup/shellbackup
path_delete=/mnt/fifth/tmp/rubbish/
limit_num=15

fileBackup()
{
set -x
#備份文件
#cp -r $1 $2/shell-`date +%Y-%m-%d-%H-%M-%S`
count=`ls $1 | wc -w`

if [ "$count" -gt "$3" ];then
    echo "-----------------limit is : $3 ----------------------"
    echo "-----------------The number of files is : $count -------"
    num=`expr $count - $3`
    echo "-----------------The excess number of files is : $num ---------"
#移動文件
    ls $1 -1rt | head -n $num|xargs -n1 -i mv $1/{} $2
    set +x
    ls -1rt $2
    echo "-----------------Moving end!-----------------"
else
    ls -1rt $2
    echo "-----------------The file is too little!-------------------"
fi
}

#備份shell腳本
fileBackup $path_backup $path_delete $limit_num

相關(guān)文章

最新評論