Finding open files in MacOS X

Have you ever tried to unmount a volume or empty the trash and got the “The operation can’t be completed because the item “MyFile” is in use.” message instead?

MacOS X comes with a command line program just for this, “lsof”.

To find the application that is keeping the file open, type the following in your Terminal window, replacing the MyFile with the actual filename:

lsof | grep 'MyFile'

The first column of the output will be the offending application’s name.

If you want to get the list of files being used by a particular application instead, substitute the MyFile with the application’s name:

lsof | grep Dropbox


Leave a Reply

Your email address will not be published.

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