Why doesn't the 'rm' command dump 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.


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.