问题
How can I retrieve the information shown in the Mac's System Profiler app programatically? I'm actually interested in the USB section if that matters.
回答1:
Take a look at the system_profiler(8) command.
回答2:
The OSX command line tool "ioreg" might give you want you want.
man ioreg
ioreg displays the I/O Kit registry. It shows the heirarchical registry as an inverted tree.
Also if you can/want to use Cocoa look at IOKit. IOKit is the OSX framework that talks to USB hardware.
来源:https://stackoverflow.com/questions/426801/obtaining-a-macs-system-profiler-data-from-shell