Site TIPS PAGE🔎 SEARCH  Ξ INDEX  MAIN MENU  UP ONE LEVEL
 OJB's Web Site. Version 2.1. Mac Tip.You are here: tip tips mac owen2 
Tip

Up to OJB's Mac Tips List

List Files Open on a Volume

A common problem is that when trying to eject a disk, flash drive, or other storage device, you are told it cannot be done because "one or more programs may be using it". Of course, you can just go ahead and unplug the disk anyway, but then the computer will warn you about that. Is there a way to tell what might be open on the disk?

There is a command line utility called "lsof" (list open files) which will list all the files the system has open. To show only those on a certain device, use the grep (global regular expression parser) command to show only those on the disk you are interested in. The command is this:

lsof | grep /Volumes/DISKNAME

Where DISKNAME is the name of your disk. If the disk has a space in its name remember to "escape" it using \, like this: /Volumes/Macintosh\ HD, or put it in quotes like this: "/Volumes/Macintosh HD". /Volumes is the folder where the Mac stores all the connected storage devices.

The "|" symbol is called a pipe and it takes the output of one command (lsof, which lists all the open files) and sends it to the input of another command (grep, which filters the text sent to it), a very powerful feature of Unix!



I usually write a blog post about once a week. The latest post can be viewed here: But is it Science?: Ask yourself this: is it really science? (posted 2024-10-04 at 12:30:35).
Warning: mysqli_connect(): MySQL server has gone away in /Library/WebServer/Documents/Owen2/Inc/Footer.inc.php on line 59

Warning: mysqli_connect(): Error while reading greeting packet. PID=27403 in /Library/WebServer/Documents/Owen2/Inc/Footer.inc.php on line 59

Warning: mysqli_connect(): (HY000/2006): MySQL server has gone away in /Library/WebServer/Documents/Owen2/Inc/Footer.inc.php on line 59

Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in /Library/WebServer/Documents/Owen2/Inc/Footer.inc.php on line 60
Could not connect to MySQL: