Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-10-2010, 01:18 PM   #1
LQ Newbie
Registered: Jul 2010
Distribution: Ubuntu 10.10
Posts: 22

Rep: Reputation: 0
Question Bash script: how to move files to Trash instead of deleting?

I've tried a number of suggestions found on the internet and none of them work. Here's one:

mv "$x" ~/.Trash/
...where $x is the pathname of the file passed to the script. I've also tried different paths to Trash - on Desktop, in Home folder, in my user folder, it makes no difference. Either nothing happens, or more often, the file is simply copied to my desktop or userfolder with the name "Trash".

What is the actual path to the Trash folder and how can I move files there? I'm using Ubuntu 10.04.
Old 07-10-2010, 01:44 PM   #2
LQ Newbie
Registered: Jul 2010
Distribution: Ubuntu 10.10
Posts: 22

Original Poster
Rep: Reputation: 0

mv "$x" /home/YOURUSERFOLDER/.local/share/Trash/files/
...where YOURUSERFOLDER is like it says. And that does it, the file is in the Trash!

I hope this helps someone else out there, as I've not seen this solution anywhere, despite a lot of searching.


bash, delete, move, mv, script, trash

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lost disk space after deleting files, trash, hidden trash, etc. themacguy Ubuntu 7 06-06-2012 03:51 AM
[SOLVED] Bash script needed to move files to another folder. No_one_knows_me Linux - General 28 01-07-2010 11:29 PM
Bash script: Move files, ignore case Fredde87 Linux - Software 3 09-03-2008 04:34 AM
After a piece of software/a bash script to mass-move files [Fedora Core 6] Alux Linux - Desktop 3 11-23-2006 03:33 PM
making a script that will move a file or files in a trash folder Paxmaster Programming 5 12-12-2004 07:00 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:52 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration