替代Linux下的rm命令

方式一:自己編寫腳本

編寫腳本del.sh

#!/bin/bash

TMP_DIR="/tmp/trash_tmp"

mv $@ $TMP_DIR


chmod +x /home/scripts/del.sh

mkdir -p /tmp/trash_tmp

chmod 777 /tmp/trash_tmp


vim .bashrc

alias rm='sh /home/scripts/del.sh

source .bashrc


如果需要使用系統默認的rm,只要用\rm即可

方式二:安裝trash

執行easy_install trash-cli安裝trash-cli,實現命令行下的回收站。項目見-trash-cli 

trash-put           trashes files and directories.
    trash-empty         empty the trashcan(s).
    trash-list          list trashed file.
    trash-restore       restore a trashed file.
    trash-rm            remove individual files from trash can.

alias rm='echo "This is not the command you are looking for, Please Use "trash"!!!"; false'


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章