The content of this section:
Keep the specified number of files remaining under the file system
Example:
Copy Code code as follows:
#!/bin/bash
#-------------------------------
#Description: Back Up your files
#site: Www.jb51.net
#-------------------------------
#shell variables
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 $ $2/shell-' date +%y-%m-%d-%h-%m-%s '
count= ' ls $ | Wc-w '
If ["$count"-GT "$"];then
echo "-----------------limit is: $----------------------"
echo "-----------------The number of files is: $count-------"
num= ' expr $count-$ '
echo "-----------------the excess number of files is: $num---------"
#移动文件
LS $1-1rt | Head-n $num |xargs-n1-i MV $1/{} $
Set +x
Ls-1rt $
echo "-----------------Moving End!-----------------"
Else
Ls-1rt $
echo "-----------------The file is too little!-------------------"
Fi
}
#备份shell脚本
Filebackup $path _backup $path _delete $limit _num