rm to mv command in linux
by Ranganathan[ Edit ] 2014-02-21 14:14:30
rm to mv command in linux
1.download trash-cli.zip from this url
trash-cli.zip download
2.unzip 7471-trash-cli.zip
3.cd trash-cli-0.1.10.r55
4.python setup.py install
5. vim /usr/local/bin/trash-rm
add the following code into trash-rm file
#!/bin/bash
# command name: trash-rm
shopt -s extglob
recursive=1
declare -a cmd
((i = 0))
for f in "$@"
do
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 -a -d "$f" ]
then
echo "skipping directory: $f"
continue
else
cmd[$i]="$f"
((i++))
fi ;;
esac
done
trash "${cmd[@]}"
6. chmod +x /usr/local/bin/trash-rm
7. add the following into .bashrc file
alias "rm=trash-rm"
8.finally run bash command
Use following command
empty-trash
list-trash
restore-trash