Move file to Trash instead of permanently deleting in Mac Terminal


When you make use of the rm (remove) command on the Mac Terminal, the files and folders are permanently deleted, you will not be finding them in the Trash. This can be really risky if you remove a folder or a file that is important by mistake because you may not be able to recover them.

In such cases, it is better to make use of the mv command instead of rm to move files and folders to the Trash folder. You can find the trash folder under your home directory. It is a hidden folder with the name .Trash.

Let's see some examples of moving files and folders to Trash using the Mac Terminal Command.


Move file to Trash using Terminal

 % mv myfile.txt ~/.Trash/

Move a folder to Trash using Terminal

 % mv myfolder ~/.Trash
move files and folders to Mac Trash using Terminal Examples
-

Facing issues? Have Questions? Post them here! I am happy to answer!


Author: Rakesh
Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

Copyright © Code2care 2023 | Privacy Policy | About Us | Contact Us | Sitemap