Make a Mac Executable File via the Command Line to Quickly Clean Your Trash
Posted on May 31, 2014 in Command Line, Linux, Mac by Matt Jennings
The commands below may also work in Linux and Unix. Both the Mac OS and Linux are based on Unix.
- Open Terminal.
- In Terminal
cd Desktop
and pressEnter
. nano clean-trash
and pressEnter
. This will bring you to Nano, a Terminal application to edit files.- Copy and post the code below into the next screen in Terminal that appears:
rm -rfd ~/.Trash/* rm -rfd ~/.Trash/.* Killall Terminal
- Press
Ctrl
+x
andEnter
. - Then you may need to press
y
orEnter
to save the file exit Nano. You will return to the Terminal shell you were at before you went into Nano and will also be in theDesktop
directory. chmod +x clean-trash
and pressEnter
to make the file executable on your Desktop. Exit the Terminal.- If everything worked correctly you will see a
clean-trash
file on your Desktop. When you click it, if there are files in your trash they will be all deleted, including hidden files like.htaccess
.