A shell command for safely deleting files the functions in the following script can be safely used to delete xxxx. This command will move the xxx file (or directory (do not add/after directory ~ /Backup, and add a Time Label at the same time. By running delete_old ~ The oldest file or directory under the/backup directory that exceeds MB is deleted, and data protection is still useful # Description: This function used to move some useless files in current folder ~ /Backup/# Author: fulinux # Version: 1.0.0 (Release by fulinux on 8th limit L. 2013) function delete () {if [-z $1]; then echo "delete it to backuo directory" echo "Usage: $ FUNCNAME [express]" echo "Example: $ FUNCNAME fulinux/"return; fi express = $1 timestamp = $ (date + % Y % m % d % H % M % S) rechristen = $1. $ timestamp mv "$ express "~ /Backup/"$ rechristen"} # Description: This function used to search dir to fetch the oldest file # Author: fulinux # Version: 1.0.0 (Release by fulinux on 8th limit L. 2013) searchdir () {oldestfile = 'LS-rt | head-n 1 | awk' {print $1} ''} # Description: this function used to remove oldest useless files in ~ /Backup folder if its size is more than 4000 M # Author: fulinux # Version: 1.0.0 (Release by fulinux on 8th limit L. (2013) # This is the directory where backup files are keptbackup = ~ /Backup # maximum useless filesalarmrate = 3000 function delete_old () {cd $ backup while true; do backup_size = 'du-ms $ backup | awk '{print $1} ''if [$ backup_size-gt $ alarmrate]; then searchdir delete $ oldestfile else break; fi done}