Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Unsupported Software
  • Search

how to make "rm" move files to a trash folder... [SOLVED]

This forum covers all Gentoo-related software not officially supported by Gentoo. Ebuilds/software posted here might harm the health and stability of your system(s), and are not supported by Gentoo developers. Bugs/errors caused by ebuilds from overlays.gentoo.org are covered by this forum, too.
Post Reply
Advanced search
8 posts • Page 1 of 1
Author
Message
randal1
Apprentice
Apprentice
User avatar
Posts: 225
Joined: Mon Oct 03, 2005 3:07 pm
Location: England

how to make "rm" move files to a trash folder... [

  • Quote

Post by randal1 » Sat Nov 25, 2006 3:18 pm

Hi All,

I would like to make the rm command move "deleted" files to a trash folder instead of wiping them off disk. Similar to how a file delete in KDE works for example.

Any ideas?

Many thanks :)
Last edited by randal1 on Thu Dec 07, 2006 3:45 pm, edited 1 time in total.
Top
lagalopex
Guru
Guru
User avatar
Posts: 567
Joined: Sat Oct 16, 2004 10:48 am

  • Quote

Post by lagalopex » Sat Nov 25, 2006 3:24 pm

My first hit by searching portage... app-misc/perltrash
Top
ciaranm
Retired Dev
Retired Dev
User avatar
Posts: 1719
Joined: Sat Jul 19, 2003 11:04 pm
Location: In Hiding
Contact:
Contact ciaranm
Website

Re: how to make "rm" move files to a trash folder

  • Quote

Post by ciaranm » Sat Nov 25, 2006 6:23 pm

randal1 wrote:I would like to make the rm command move "deleted" files to a trash folder instead of wiping them off disk. Similar to how a file delete in KDE works for example.
That's a very bad idea -- even worse than that alias rm="rm -i" thing that some people use.

As soon as you move onto a box that doesn't do this, you're going to rely upon being able to recover from mistakes and find yourself with lots of deleted things that you can't get back.
Paludis 0.12, 127.35% Portage compatible and six times faster.
Top
arghnoname
Tux's lil' helper
Tux's lil' helper
Posts: 84
Joined: Sun Mar 13, 2005 5:52 am
Location: Washington, DC

  • Quote

Post by arghnoname » Sat Nov 25, 2006 6:59 pm

I don't know if this is a great idea, but the easiest thing would be to create ~/bin, make sure it's at the front of your $PATH
in ~/.bash_profile

Code: Select all

export PATH=~/bin:${PATH}
and create a perl, python, c, shell...whatever sort of script called rm and make it u+x in that ~/bin file.

~/bin/rm

Code: Select all

#!/bin/bash
#write script here that does what you want. for a poor (but mostly working) example of rm emulation...
mv "$@" ~/.shtrash/
Top
zAfi
Apprentice
Apprentice
User avatar
Posts: 220
Joined: Tue Aug 08, 2006 7:49 pm
Location: Austria

  • Quote

Post by zAfi » Sat Nov 25, 2006 8:48 pm

ciaranm is right! you shouldn't change the rm behaviour!!!!
Instead, you could for example make a little script called _del_ that does exactly what you need. (moving the file to a destination/trash-folder) like arghononame suggested.
Gentoo 2008.0/desktop | Kernel: 2.6.27-tuxonice | Arch: amd64 | KDE 3.5.9 | WU Wien |
----------
Share your kernel information @ http://klive.cpushare.com/
Top
PaulBredbury
Watchman
Watchman
User avatar
Posts: 7310
Joined: Thu Jul 14, 2005 3:47 pm

  • Quote

Post by PaulBredbury » Sat Nov 25, 2006 9:45 pm

For a bit of light amusement, there's a section on the joys and pitfalls of rm in the Unix-Hater's Handbook :)
Top
Conan
Guru
Guru
Posts: 360
Joined: Tue Nov 02, 2004 1:26 am

  • Quote

Post by Conan » Sun Nov 26, 2006 1:28 am

The most implemented way is to utilize libtrash. I believe its in portage but cannot check right now. libtrash wraps glibc calls in order to prevent things from being deleted. Note what ciaran said is something to keep in mind, but it's all up to you.
Top
randal1
Apprentice
Apprentice
User avatar
Posts: 225
Joined: Mon Oct 03, 2005 3:07 pm
Location: England

  • Quote

Post by randal1 » Thu Dec 07, 2006 3:45 pm

Hi,

Thank you for all your replies...I have taken these into consideration and found a result I am happy with. I have created a bash script called 'del' under /usr/local/bin that moves the files given to Kde's Trash...

Code: Select all

#!/bin/sh
kfmclient move "$@" trash:/
This means I won't get confused with 'rm' when on other peoples computers and I can still get the files back if I decide that I want them. As I work with two users, personal and root, I created a link to root's trash can from my personal kde desktop.

Thank you :)
Top
Post Reply

8 posts • Page 1 of 1

Return to “Unsupported Software”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic