rm to wastebin?

Is there a way to delete files on the commandline that uses the KDE-Wastebin?

It appears that I never ever need the KDE4 Wastebin for files that I deleted through Konqueror or Dolphin. It is only when I delete files on the konsole with rm that I wish I could undelete them. :beat-up: It always happens like that, mostly by being in the wrong directory or using a wildcard when I should not have.

(I don’t have any erroneous deleted file right now, and I do have plenty of backups, but I just wonder whether there is something better than rm to use generally on the commandline.)

you can make an alias rm=‘rm -i’ to avoid mistakes. It will prompt before removal.
Create the file ~/.alias if it doesn’t exist and write this line in it:
alias rm='rm -i’
I think it is sourced by ~/.bashrc. Open a new terminal and type: alias to display the currently defined aliases.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Close… your case for the commands is all wrong. You CANNOT has “ALIAS
RM=‘RM -I’” and expect it to work as neither ALIAS nor RM are commands.

alias rm=‘rm -i’

Good luck.

please try again wrote:
> you can make an alias rm=‘rm -i’ to avoid mistakes. It will prompt
> before removal.
> Create the file ~/.alias if it doesn’t exist and write this line in
> it:
> ALIAS RM=‘RM -I’
> I think it is sourced by ~/.bashrc. Open a new terminal and type:
> alias to display the currently defined aliases.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJLah9fAAoJEF+XTK08PnB5ZPcP/iSk4RGY41Leu0lADVdDpC5P
p796fem4plOxTPDGpBLnecTiWhDuqqrL8K2Nhqx/iGKmq/4Wp56kHb0HCMrm5jjD
TsH0kUH1ZhQ83cXJH2cwbVBk4s9aUhXV7wZPUydIiwZ1+9wn5V588aKl8CaWGi5G
MV2f1v4oRciRKIOGDagQWNyGkB3uFRjMBHiKnqyF/3lJ2hvPByc6silOxuV/pvU0
w76zQ8AqL7uvtTWmxLWVF720QPu6QADTqusbyFiP0okwl4CDnrqWq+Gh4kQmVZtE
sZXyHkslaUx/MK78WFPb23v4aWvT/DDmaP8ZcE55CAHBtrGuBQ3xdB2ChRDgWbQU
MJ38zmgRVBs3zuSGkUuOB/o5uRZ47lcJfoY836Q5j16xVzgiLorIDT4fP7Im6/zp
yPQpB0d9B1Etc9wKofCaOTQ+3Oa7snKClisGspy7sYGqiVXW/bSaJS05lbsPx6jT
7oWdpKPQP0Lgs74tfcjUhIx9R/QCphNrP2D0CU57wiJM9v8jF4Vq/jqnGfRT3wTh
SMQm65PwQ5wI+wHF+3cQOaU3Tsdd74JFPvzJLnV6IJ+01CuKXZKiYKhr0T8x6gSr
GcgDDK5iNeoGlba38Vwc8GxgN0qJT+flKmHI3y+jRvFnuDZHyen8tH1/kd1UslRB
hMRVHg/Yde4TadxO7UBJ
=zvJe
-----END PGP SIGNATURE-----

Definitely! But I never wrote this commands it all caps (?!). I just highlighted that line in bold. Is that a browser display issue on your side?

What do you read here :
alias rm=‘rm -i’ ?
and here :
alias rm=‘rm -i’ ?

The first line should be in bold (not in caps!)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

They do not have bold at all… I’m not using a web browser to view the
forums. Sorry about that… the NNTP showed the characters in caps,
though now they do not with your recent example (first had asterisks on
either side, second did not).

This may be a conversion thing between the web forums and the NNTP
applications.

Good luck.

please try again wrote:
> ab@novell.com;2114854 Wrote:
>> Close… your case for the commands is all wrong. You CANNOT has
>> “ALIAS
>> RM=‘RM -I’” and expect it to work as neither ALIAS nor RM are
>> commands.
>>
>
> Definitely! But I never wrote this commands it all caps (?!). I just
> highlighted that line in bold. Is that a browser display issue on your
> side?
>
> What do you read here :
> alias rm=‘rm -i’ ?
> and here :
> alias rm=‘rm -i’ ?
>
> The first line should be in bold (not in caps!)
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJLalKQAAoJEF+XTK08PnB5T4kP/R7SfO2IfQBpUelg0URsOq73
PnwkZzks9ZRaQGZj5CWvYgIXoogtpdt/4FcuEKjUphpwQ28Vn2EE7Qzbr0nGhEfY
P8ktmbqsCE/k/JhDYns+IIMbvASBt9bVcreQ6b10Pwt5+rGHN7WoGppwDbTopEIe
Odw2dVbAJyXCt3eFGP3wKOo/cpct2z2VQDOS/rbhnHgDw2LlV1q2ZQf5NjkRJ369
lID6wCRUuwwFSgudoFypzO+FLqttDgYlivtEfHNINhHofQInXL+hnOE/SpOwWBQ/
A+FAPyGEKYTXsB6Bvbs9G3msTCJOB7IvjXkpMbSBbERs079OtLbgx2OV0EbEpO3P
N/vHQqY0SWMuJw35z9BdfOHR93d38Usbna2QenW20gSlDgC0aJ+iTiUhVDf3sSb9
Ej/d0pVI/zl0Wi93MCatNek+PjK/k2Lu8ul/U/XIS9R2V29U65LsdBE/6qOBd+xr
U8KJHfEjUMPxlkzeez53MIXwvJKuEpMzQN+JDqQQOnymZ37gtGoRVzwy5DlP9USd
7myX/Z/FNqssIhTuxxqvFNKFiP5eHwGThHf5IoMtwOdXYLG4ydcL0usBtmvPIpCd
wH1JbV5rdlHeKz5hm9AJCrUZswDBNYenOAcyLUHFh/REy4HLMX+q+UFI4JUrsgGw
99dxYzgNTupgtLpJfX9f
=2/zm
-----END PGP SIGNATURE-----

On Thu, 04 Feb 2010 04:52:33 +0000, ab@novell.com wrote:

> This may be a conversion thing between the web forums and the NNTP
> applications.

It is a known issue. Happens from time to time.

Jim


Jim Henderson
openSUSE Forums Moderator

please try again wrote:
> you can make an alias rm=‘rm -i’

couldn’t you (instead of using rm) use move to send stuff to your
trashcan, like:

mv [/path/filename] ~/.Trash

if you wish, you may add -i (after mv) to have it prompt you for a y
(yes) prior to execution…

and, i guess you could make a tiny script allow you to just type

mvT [/path/filename]


palladium

Option -i is certainly not what I want, since the comamndline is meant to be faster, not slower than point & click, so I pretty much always use -f instead. Also, it is usually a day later that I realize the wrong thing has gone.

I tried a script to move files to ~/.local/share/Trash/files/ but then they do not show up in the Trashcan, which is inconvenient. Worse, I doubt that they get automatically deleted from the Trashcan once they expire the Trashcan’s set expiry date.

So isn’t there a shell script or DBUS-something that can trigger the same functionality from the commandline as deleting does in Dolphin?

Here’s what happens when you move a file to the trashcan under KDE. Let’s take the file /home/stan/doc/hello as example.

Moving this file to the trashcan will:

  • create the directories /home/stan/doc/.Trash-0/files and /home/stan/doc/.Trash-0/info if that don’t already exist. Notice that /home/stan/doc/.Trash-0 is a hidden directory.
  • move the file /home/stan/doc/hello to /home/stan/doc/.Trash-0/files
  • write a relative path and deletion date in the file /home/stan/doc/.Trash-0/info/hello.trashinfo

It’s not difficult to write a script which would do that. And I’m sure many people did already. Just googled and found that page:

Command line to trash - Unix Linux Forum - Fixunix.com

I haven’t looked at it. I’m sure you will find others (or write your own :wink: … )

STurtle wrote:
> I tried a script to move files to ~/.local/share/Trash/files/

why would you pick that path when what i wrote actually works:

mv [/path/filename] ~/.Trash

well, it works here (file disappears where it was and reappears in
Trashcan), i have no idea why it wouldn’t work there…

as for automatic emptying, no idea…


palladium

All that does here is rename the file and move it to the user’s root directory.

Are you moving the files in super user mode? That would move them to root’s trash bin.

chief sealth wrote:
> All that does here is rename the file and move it to the user’s root
> directory.

hmmmm…i guess there is a difference then in the layout of (what?)
kde4 on 11.2 vs what i’m running (kde3 on 10.3)

but, i can’t see why it move a file to your home’s root when it should
(imo) give an error: “~/.Trash does not exist” or similar… ??


palladium

“mv” is used for renaming files. There is no “ren,” “rename,” in *nix.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

‘mv’ is for moving files. Renaming is essentially the same thing since
you move it from /path/to/source.ext to /path/to/dest.ext. Unless you
actually change filesystems your inode is the same for either a move or
rename operation.

There IS a ‘rename’ command as well, and it is very good at renaming
files, but it is made to do so for multiple files at a time (see the
manpage for details).

Good luck.

chief sealth wrote:
> palladium;2115147 Wrote:
>> but, i can’t see why it move a file to your home’s root when it should
>> (imo) give an error: “~/.Trash does not exist” or similar… ??
>
> “mv” is used for renaming files. There is no “ren,” “rename,” in *nix.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJLawOaAAoJEF+XTK08PnB5qMIQAKPzwTGQuJ4t1YQVwHuQLp/P
tsMa7BgVGB6PIJXdY+KxIEFcqOMD08+sSYRLNEFfmwekl4Tdsawu4gDrAxVHUeGY
p/mDFA0KxypmA9DnmhApfiONN7T8KkXEbxJwN8lIHPZGyalhXbAJN/ZihYBouKZ2
LkkTQLOxr6L0KytHSNWYjTL9sUYNdAtsX+MBmli2EsFdJQkdRBVBymml2st7XMYA
5DhubQACTJMRP12k4TIT2aaj8q5oMuLqf3IgZ67g1bxy1KZr8WCFihjSnWiJLB1T
faPuz/GuuO9UaKqMIF+vyYFKMbOoBhJe3ll29rw8YVTz2xV0IRMM8l0SpmlBWs+8
NJne1eAa7WQZIUwN+2fYfuJMBbeT7VLpg7ZvI1RM2f+C/JL1e2jSbWv8r8COGD4C
oGbmu9fXeCLTsm1TL6bgYdrfmrPHcLufbtLJiEs11q/ImL9NM1/aN/MLNKDeGs8X
IILFINdMiYG8gTemm7coEvfANOirWetoAR1DYMGBxZiVKkcoIOGGqjcFYkkm4ubT
WhnkK7FgfwMQmfcJdNFH8hEZbQpSjTEg9xGBZ7PaozE+Zs0dAD5+RJDN6Yk5QSJg
ADO334DVO86OYYcOgvFT4cOdzGjs2sRyIbCqsTotD1XZjpmL1HtjgjPTaUG/SdGj
Lb1cJg619X9fxeWg0Bax
=Edgc
-----END PGP SIGNATURE-----

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The “trash” has some magic to it… how else can it know to ‘Restore’ one
file to your Desktop and another to a directory within your desktop?
These metadata (stored as ‘please try again’ mentioned) are why simply
moving things to ~/.Trash will not make everything happy. I have a
~/.Trash still on my system for my user, though nothing is ever in it.

Good luck.

palladium wrote:
> chief sealth wrote:
>> All that does here is rename the file and move it to the user’s root
>> directory.
>
> hmmmm…i guess there is a difference then in the layout of (what?)
> kde4 on 11.2 vs what i’m running (kde3 on 10.3)
>
> but, i can’t see why it move a file to your home’s root when it should
> (imo) give an error: “~/.Trash does not exist” or similar… ??
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJLawPpAAoJEF+XTK08PnB5OAEP/RVdlMMzoUyfxXsIsTpLoCS2
f46x7JIQhKaiAruPdquM9cCDYzyG9oKFC0aTraaHsV9V7xOiA4+V29O73xU6gDKA
BryzLyVdoQh79OfZzr6AvASeHKuJj6SYZC/h6UlgF2Ex93jqY19LnrDe8xpdaKG+
6hOYvCEFalE2UoVND+sS8pDYYgmf2m1SdGrDl0+V/1WgbOsgdMRagMGItQGMQSMS
NI240yLd2EejWdXTTvI2Dx6qwRw7Ml8OZwdOsB0iydQ4oSg/IL/sNIF3ctKMWy1B
7753ylNF3rfY7sFdWWuqMf0twQMLIt6nzTJFd6PihqqUTDRF2PUqUHkahFK6U5Wc
chlI5ati7JRZjiMonhu8KinQ4u5DR3pbqYIKlqKFldWrAJ//LlFt3IB/QUJ2MMF5
1pOhn8F07FAtNicTQ2hWdOO70gQh1oGTW2i5EVoi18hvOJ1lcJtHwAHA7uCOWXVC
XgOjRQfphHVI944YfD+QIiqdeFIFHfySTqiKYIxbkiwpBX+oOib8n3keQk5ddoFl
HkJzlGkx1L7jfcUsbC54N6WKa8g8dUXJRsdXTYc8gLqYBY/TFP54zI72Om2az4zv
1pkRZwavK0F18VX2W9n9bY4sd8K3NoWBWaJ/zPNCKfA9GxwlDz2VUrDvyX9+BWTA
xlFpjbPUH9pgV7wQGvPP
=SMQY
-----END PGP SIGNATURE-----

You’re right! :slight_smile: I guess in most of the documentation I’ve read, mv has been the most commonly used. Somewhere along the way I must have had it ingrained in my head this was the only way.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yes… and the say you need rename you will LOVE it.

Good luck.

chief sealth wrote:
> ab@novell.com;2115151 Wrote:
>> There IS a ‘rename’ command as well, and it is very good at renaming
>> files, but it is made to do so for multiple files at a time (see the
>> manpage for details).
>
> You’re right! :slight_smile: I guess in most of the documentation I’ve read, mv has
> been the most commonly used. Somewhere along the way I must have had it
> ingrained in my head this was the -only- way.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJLawhiAAoJEF+XTK08PnB5logQAKGqG1rfFv1CaEHWDKi92wZ0
EDGNVMu+BPxb86gUxitxQQomDtCzqmQdwcHJ3baU7damrx2ejQNTarLIDS252iqV
6PNptEiiD8PWZH9vfK1P1NmmD+jAT5s/YTvokqswRgGIBDlNOefqghzxE3R0iBn0
6b5pVkW0bVE0btEuSoPHzMACrzxDtj1+asT3StBgT5qb7bef9U17tDHTOZ5OO5Zj
2uNdlhgDEnRHawqvO4gVqdiJ9zP1HDg311uImqp6h+El00gS+kdna+lMkg54PAM2
+KfOPDV9vRDMScZtjATvsNru9qGfJWNuGZpLQgY61AKG8UbG2DQOXpOqxPPowcHI
hu9qsSft131yC8qPC7/Lbcwt3ioUzSm7xThoprpXnUY4Pe0d26UGpGgq9KWBp3Kv
m8HLOh5hzS21Yjfg+2QvbwQQC+EEiTn1qd/awSVbinfsCU03v9VDab4R+rZJVCeh
pLB7ZWseWpo7WtQ57xmXUvqsr+TtKOs0NkAVLAvmpC59J2Z2bc1tsE+NLMn3ycv3
3NiDdEuWF85sEv46HcqmcKDF4AMRM+n+lLmUni/2Om1aVpt/3i/EfJ+kOC6h82bc
WK/IdBs0uFG84CJdQl//mA4CU8N7VC/FfHFMXNRzOK84fO1utfaWnsYeUFHx6aRC
4y1zO/xlbXS/mHylxJJU
=TBzQ
-----END PGP SIGNATURE-----

chief sealth wrote:
> “mv” is used for renaming files. There is no “ren,” “rename,” in *nix.

i just love it when a REAL expert sets me straight… lol


palladium

ab@novell.com wrote:
> The “trash” has some magic to it…

i see now it is more complicated than i thought…however i know mv
is short for move, and it 1) moves, 2) renames 3) moves and renames,
and 4) deletes (well, actually only puts stuff in the magic trash)…


palladium