In a generic, modern unix environment (say, GNU/Linux, GNU/Solaris, or Mac OS X), is there a good way to determine which mountpoint and filesystem-type a particular absolute file path is on?
I suppose I could execute the mount command and manually parse the output of that and string-compare it with my file path, but before I do that I'm wondering if there's a more elegant way.
I'm developing a BASH script that makes use of extended attributes, and want to make it Do The Right Thing (to the small extent that it is possible) for a variety of filesystems and host environments.
df -Pshould produce standardized output on any POSIX compliant system. Some goofier systems might require a magic environment variable, such as POSIXLY_CORRECT, to be set as well. – Dan Moulding Nov 04 '14 at 18:13df /path-to-the-directorywill give you the containing partition of that directory – Hasanuzzaman Sattar Jun 23 '18 at 06:15