(Up to OJB's Mac Tips List Page)
List Files Open on a VolumeA 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!
|