Ubuntu under RM instructions redirection

Source: Internet
Author: User
Tags min

1. Install TRASH-CLI

sudo apt-get install trash-cli
2. Set up the script

sudo gedit/usr/local/bin/trash-rm

Copy

#!/bin/bash
# command name:trash-rm
shopt-s extglob
recursive=1
declare-a cmd
((i = 0)) for
F In "$@" does case
"$f" in
(-* ([Fiiv]) r* ([Fiiv]) |-* ([Fiiv]) r* ([Fiiv]))
tmp= "${f//[rr]/}"
if [-N " $tmp "]
then
#echo" \ $tmp = = $tmp "
cmd[$i]=" $tmp "
((i++))
fi
recursive=0;;
(--recursive) recursive=0;
(*)
if [$recursive! = 0-  D "$f"] then
echo "Skipping directory: $f"
continue
else
cmd[$i]= "$f"
((i++))
fi;
Esac
done
trash "${cmd[@]}"
Update:starting with Ubuntu 12.04 precise pangolin, TRASH-CLI provides the command "Trash-put" to trash files, instead o F the previous "trash" command, so in the ' code above, on the last line, replace ' trash ' with ' trash-put ' for Ubuntu 12.04 + .

Then

sudo chmod +x/usr/local/bin/trash-rm

3. Create an alias for "RM" to use "TRASH-RM"

Gedit ~/.BASHRC

Alias rm= "Trash-rm"

Bash

4. Final TRASH-CLI Tips

Trash-empty Empty the Trashcan (s).
Trash-list list trashed file.
Restore-trash restore a trashed file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.