#!/bin/bash which dmidecode >/dev/null if [ $? -ne 0 ]; then echo dmidecode not found exit 1 fi serial=`dmidecode | grep -im1 'serial number' | cut -d' ' -f3 | tr -d [:space:]` if [ ${#serial} -eq 0 ]; then echo no serial found exit 1 fi echo $serial