1 2 3 4 5 6 | realrm="/bin/rm" if [ ! -d ~/trash ] then mkdir -v ~/trash chmod 777 ~/trash fi |
1 2 3 4 | if [ $# -eq 0 ] then echo "Usage:delete file1 [file2 file3....]" echo "If the options contain -f,then the script will exec 'rm' directly" |
1 2 3 4 5 6 7 8 9 10 11 12 | while getopts "dfiPRrvW" opt do case $opt in f) exec $realrm "$@" ;; *) # do nothing ;; esac done |
1 2 3 4 | echo -ne "Are you sure you want to move the files to the trash?[Y/N]:\a" read reply if [ $reply = "y" -o $reply = "Y" ] then ##### |
1 2 3 4 5 6 7 8 9 10 11 12 | for file in $@ do if [ -f "$file" –o –d "$file" ] then if [ -f "$file" ] && [ `ls –l $file|awk '{print $5}'` -gt 2147483648 ] then echo "$file size is larger than 2G,will be deleted directly" `rm –rf $file` elif [ -d "$file" ] && [ `du –sb $file|awk '{print $1}'` -gt 2147483648 ] then echo "The directoryfile is larger than 2G,will be deleted directly" `rm –rf $file` |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | now=`date +%Y%m%d_%H_%M_%S` filename="${file##*/}" newfilename="${file##*/}_${now}" mark1="." mark2="/" if [ "$file" = ${file/$mark2} ] then fullpath="$(pwd)/$file" elif [ "$file" != ${file/$mark1} ] then fullpath="$(pwd)${file/$mark1}" else fullpath="$file" fi echo "the full path of this file is fullpath" if mv -f $file ~/trash/$newfilename then $(/logTrashDir "$newfilename $filename $now $fullpath") echo "files: $file is deleted" else echo "the operation is failed" fi |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |