Using the rm 'filename' command, i have noticed that the file isn't actually deposited into the trash. I realise that this isn't completely removing the file from the computer, however im perplexed as to why it would not appear in the trash?

In short:

Why doesn't the 'rm' command deposit file in trash.


rm is a standard Unix command and Unix does not always have trash. At the programming level the BSD API does not have a system call to trash a file, Apple supplies those at a higher level.

Also you need a command that deletes files e.g. to remove them from trash and rm happens to be it. You need another command to put a file in trash.

|improve this answer|||||
  • I think that the command that emulates (is executed) when Secure Empty Trash is run is srm not simply rm. From man srm srm removes each specified file by overwriting, renaming, and truncating it before unlinking. This prevents other people from undeleting or recovering any information about the file from the command line. – AMR Jul 22 '15 at 21:47

Actually when you use 'rm' you are deleting the file directly. When you delete a file from the Finder it actually moves it to the Trash, that is it doesn't delete it.

If you want to move the file to the Trash instead of deleting it try:

mv fileName ~/.Trash/

What this does is it moves the file called fileName to your user's trash. The '~' means your user's directory and .Trash is your trash (the dot before Trash means it's a hidden file). After trying this command open the Trash from the finder and your file should be there.

Also, if you want to play around with files I would recommend to use fictitious files. You can easily create files using the touch command which creates an empty file if it doesn't exist:

touch newFile

So if you want to test my solution you should do this (where $ is the prompt):

$touch newFile
$mv newFile ~/.Trash/

And you should see newFile in the Trash.

|improve this answer|||||
  • Moving a file to the Trash in the Finder , moves the file to its respective Trash directory on that file system. Your proposal can be dangerous. – fd0 Jul 7 '15 at 15:27
  • That's why I recommend using fictitious files so you don't mess up you system :o – loco.loop Jul 7 '15 at 15:40

You may want to use rmtrash (available on http://www.nightproductions.net/cli.htm or using homebrew), which moves a file to the trash.

|improve this answer|||||

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .