°²È«µÄrm -rf ÈÃÄãÔÚLinuxɾ³ýµÄÎļþÓеط½ÕÒ»Ø
Ò»¸ö²»Ð¡ÐÄrmµôÎļþÁË°É£¿
ºó»ÚĪ¼°ÁË°É£¿ºÃ²»ÈÝÒ×±àдµÄ³ÌÐò»òÕßÖØÒªÐÅÏ¢ÕÒ²»»ØÀ´ÁË°É£¿
°ÑÕâ¶Î´úÂë¼ÓÈëÄãµÄhomeĿ¼µÄ.bashrc»òÕß.zshrc¾Í¿ÉÒÔÁË
¹¤×÷ÔÀí£º
ÔÚÄãµÄhomeĿ¼»á´´½¨Ò»¸ö.trashÎļþ¼Ð
ÀïÃæ»á°´ÕÕɾ³ýʱ¼ä Äê_ÔÂ_ÈÕ/Сʱ_·Ö_Ãë/ ½øÐй鵵ÒÑɾ³ýµÄÎļþ
È»ºó»áɾ³ýÒ»¸öÔÂÒÔÇ°µÄÎļþ¼Ð
¾ÍÊÇÕâÑù£¡
function rm() { # garbage collect now=$(date +%s) for s in $(ls --indicator-style=none $HOME/.trash/) ;do dir_name=${s//_/-} dir_time=$(date +%s -d $dir_name) # if big than one month then delete if [[ 0 -eq dir_time || $(($now - $dir_time)) -gt 2592000 ]] ;then echo "Trash " $dir_name " has Gone " /bin/rm $s -rf fi done # add new folder prefix=$(date +%Y_%m_%d) hour=$(date +%H_%M_%S) mkdir -p $HOME/.trash/$prefix/$hour if [[ -z $1 ]] ;then echo 'Missing Args' return fi #check force? check rmdir? force_file="n" force_dir="n" for arg in $@; do if [[ "$arg" = "-"* ]] && [[ "$arg" =~ "f" ]];then force_file="y" fi; if [[ "$arg" = "-"* ]] && [[ "$arg" =~ "r" ]];then force_dir="y" fi; done; for file in $@; do force="n" if [ -e $file ];then #check is dir? if [ -d $file ];then if [ $force_dir = "n" ];then echo "rm: cannot remove "$file"/: Is a directory" else echo "Trashing dir : "$file mv $file $HOME/.trash/$prefix/$hour fi else if [ $force_file = "y" ]; then echo "Trashing "$file mv $file $HOME/.trash/$prefix/$hour else read -p "rm: remove regular file "$file" ?" force case "$force" in y|Y|Yes|YES|yes|yES|yEs|YeS|yeS) force="y" ;; n|N|No|NO|no|nO) force="n" ;; *) esac if [ $force = "y" ]; then echo "Trashing file : "$file mv $file $HOME/.trash/$prefix/$hour fi fi fi fi done; }
ÍƼöÐÅÏ¢
- linuxÃüÁîѧϰ±Ê¼Ç£¨11£©£ºnlÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨5£©£ºrmÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨4£©£ºmkdirÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨1£©£ºlsÃüÁî
- ½«CentosµÄyumÔ´¸ü»»Îª¹úÄڵİ¢ÀïÔÆÔ´
- ʹÓÃNginxÌí¼Óheader·ÀÖ¹ÍøÒ³±»frame
- linuxϼÓËÙscp´«Êä´óÎļþµÄËÙ¶È
- linuxϵͳÉ϶ÔnginxÈÕÖ¾·Ö¸î´¦Àí
- lnmp/nginxϵͳÕæÕýÓÐЧµÄͼƬ·ÀµÁÁ´ÍêÕûÉèÖÃÏê½â
- Í»ÆÆÊ®Íò²¢·¢µÄNginxµÄÅäÖü°ÓÅ»¯
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- ²éÕÒ²¢É¾³ý.svnĿ¼Îļþ
- redis ÆßÖÖÊý¾ÝÀàÐ͵ÄʹÓó¡¾°
- linux ÏÂÎļþ¸´ÖƵ½windowsÏÂÂÒÂëµÄ½â¾ö°ì·¨
- nginx³öÏÖ502 upstream sent too big he....
- linuxÏÂsudoÅäÖÃÏê½â
- linuxÃüÁîѧϰ±Ê¼Ç£¨15£©£ºtailÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨14£©£ºheadÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨13£©£ºlessÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨12£©£ºmoreÃüÁî
- ¼ÓÃÜËã·¨±È½Ï3DES AES RSA ECC MD5 SHA1µÈ
ÆÀÂÛ