1. Create a directory under / home / username / directory named: .trash
2 .. at / home / username / tools / directory, create a shell document, named: remove.sh
#!/bin/bash
PARA_CNT=$# TRASH_DIR="/home/username/.trash" for i in $*; do STAMP=`date +%s` fileName=`basename $i` mv $i $TRASH_DIR/$fileName.$STAMP done
3. Modify ~ / .bashrc, add the line (if the root user to modify / etc / profile)
alias rm="sh /home/username/tools/remove.sh"
4. Set the crontab, periodically empty trash, such as:
crontab -e 0 0 * * * rm -rf /home/username/.trash/*
5. source ~ / .bashrc so that replacement takes effect immediately (root user source / etc / profile)
For ease of use, it was made into a button xshell
mkdir -p /home/username/.trash mkdir -p /home/username/tools
cat << EOF > remove.sh
> #! /bin/bash
> PARA_CNT=$#
> TRASH_DIR="/home/username/.trash"
> for i in $*; do
> STAMP=`date +%s`
> fileName=`basename $i`
> mv $i $TRASH_DIR/$fileName.$STAMP
> done
> EOF