How to get serial number from Mac hard disks?

后端 未结 7 786
遇见更好的自我
遇见更好的自我 2020-12-01 10:10

Is there an easy way to get the serial number of all the hard disks in a Mac using an API?

Basically, I\'m looking for a unique identifier for the hard disk with whi

7条回答
  •  借酒劲吻你
    2020-12-01 10:28

    The following will list the serial numbers on the SATA-bus. You don't get to know which device it is as is but you can do it with some scripting/parsing. I've used "sed" to remove all the spaces and "awk" to isolate just the serial in case you are not familiar:

    $ system_profiler SPSerialATADataType -detailLevel medium | grep Serial | sed -e 's/[\<\>\"\ ]//g' | -F':' '{print $2}'
    

提交回复
热议问题