Skip to content

Instantly share code, notes, and snippets.

@markuskont
Created May 4, 2016 08:56
Show Gist options
  • Save markuskont/8643199caadf6f291c32f1dd6dc237c5 to your computer and use it in GitHub Desktop.
Save markuskont/8643199caadf6f291c32f1dd6dc237c5 to your computer and use it in GitHub Desktop.
Get kind of unique number for system.
#!/bin/bash
SERIAL=`sudo hdparm -I /dev/sda | grep 'Serial Number:' | perl -ne 'if(m/:\s*(\S+)/){print "$1\n"}' | tr -cd 0-9`
UNIQUE_FILE='/tmp/uniq.txt'
grep $SERIAL $UNIQUE_FILE > /dev/null 2>&1 || echo $SERIAL > $UNIQUE_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment