国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

linux下保留文件系統下剩余指定數目文件的shell腳本

2019-10-26 18:37:38
字體:
來源:轉載
供稿:網友

本節內容:
保留文件系統下剩余指定數目的文件

例子:

代碼如下:
#!/bin/bash
#-------------------------------
#Description: Back up your files
#site: www.jb51.net
#-------------------------------

#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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 淮阳县| 昌乐县| 雷山县| 怀化市| 平阴县| 沭阳县| 汉沽区| 宝清县| 陕西省| 玉门市| 新龙县| 黎城县| 永顺县| 扎鲁特旗| 涡阳县| 鸡东县| 页游| 老河口市| 杨浦区| 当雄县| 宜黄县| 八宿县| 施甸县| 崇文区| 垣曲县| 庆元县| 岳阳市| 禄丰县| 清涧县| 长顺县| 峨眉山市| 体育| 攀枝花市| 南漳县| 周口市| 柳江县| 涞水县| 云霄县| 竹溪县| 阳东县| 咸阳市|