Verbosely emptying the trash

Like it happens on Windows, when you decide to delete something OSX simply moves that file or directory to “the Trash”, which is just a hidden directory on the volume you’re deleting from. Then, you right click on the Trash icon and select “Empty trash”.
This action pops up a small window like this:

osx trash progress window

I grew tired of asking myself what OSX was deleting (the operation can take a while, especially when — as I often do — you’re doing a secure erase) so this ugly one-liner, run as root, will give you the file the OS is working on:


ps auxw | grep -i locum | grep -v grep | awk '{print $2}' | xargs lsof -p | grep -i Trash | awk '{print $9}'

It will output something like this:
/Volumes/FAT80GB/.Trashes/502/xcode3210a432.dmg

You can wrap that command inside the usual while/sleep loop if you want something that keeps you updated on what is going on — or make it an alias for your favourite shell.

Author: zen

Geek of all trades, having fun with *NIX, the Internet and computer security since 1995.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close