#!/bin/bash

os_name=`uname`
cpu_serial=""
main_board_serial=""

if [ $os_name = "Linux" ] 
then
    cpu_serial=`echo $(dmidecode -t processor | grep 'ID' | awk -F ':' '{print $2}' | head -n 1)`
    main_board_serial=`echo $(dmidecode | grep 'Serial Number' | awk -F ':' '{print $2}' | head -n 1)`
else
    cpu_serial=`echo $(system_profiler SPHardwareDataType | fgrep 'UUID' | awk '{print $NF}')`
    main_board_serial=`echo $(system_profiler SPHardwareDataType | fgrep 'Serial' | awk '{print $NF}')`
fi

echo "操作系统:${os_name}"
echo "CPU序列号:${cpu_serial}"
echo "主板序列号:${main_board_serial}"