Specifically, I wanted to find out the mount point of a file system. I know the device file of the disk partition/slice.
I could try the mount command, but if the mount point directory has whitespace characters, parsing the output of the mount command is a bit fragile.
diskutil info is an OS X specific command that gives me what I want. After learning about XPath a bit, I came up with something like this:
diskutil info -plist /dev/disk0s2 | xpath "//string[preceding-sibling::key[1]='VolumeName']"
This is not yet perfect. The volume name is surrounded by <string> and </string> but I can live with that. The final insight for the XPath expression came from this post.
P.S. This post was written in Blogger's rich text editor in the Safari browser. This was the first time it worked well enough to be useful.
1 kommentti:
I'm sure there is a way to refer to contents of an element in XPath.
Lähetä kommentti