首页 > 移动平台 > 详细

rm命令修改为移动到回收站

时间:2015-03-25 12:00:48      阅读:282      评论:0      收藏:0      [点我收藏+]
vi .bashrc

# .bashrc

# User specific aliases and functions

alias rm=trash
alias cp=‘cp -i‘
alias mv=‘mv -i‘
alias r="rm -i"
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
trash()
{
    MYVAR=$@
    mv ${MYVAR#-* } /recycle
}

  附加一个定时清理回收站脚本

import os
def removeDir(dirPath):
    if not os.path.isdir(dirPath):
        return
    files = os.listdir(dirPath)
    try:
        for file in files:
            filePath = os.path.join(dirPath, file)
            if os.path.isfile(filePath):
                os.remove(filePath)
            elif os.path.isdir(filePath):
                os.rmdir(filePath)
        #os.rmdir(dirPath)
    except Exception, e:
        print e
removeDir(r‘/recycle/‘)

  crontab 添加

0 23 * * 6  python /clear.py

rm命令修改为移动到回收站

原文:http://www.cnblogs.com/huangjianan/p/4364998.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!