Skip to content

Instantly share code, notes, and snippets.

@tehnoir
Last active September 24, 2018 19:41
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tehnoir/312ae605068616f8d6f0 to your computer and use it in GitHub Desktop.
Save tehnoir/312ae605068616f8d6f0 to your computer and use it in GitHub Desktop.
getudid
#!/bin/bash
function getUDID {
udid=($(system_profiler SPUSBDataType | grep -A 11 -w "iPad\|iPhone\|iPod\|AppleTV" | grep "Serial Number" | awk '{ print $3 }'))
if [ -z $udid ]; then
echo "No device detected. Please ensure an iOS device is plugged in."
exit 1
else
for id in "${udid[@]}"; do
if [ ${#id} -eq 24 ]; then
id=`echo $id | sed 's/\(........\)/\1-/'` # Add proper formatting for new-style UDIDs
fi
echo -n $id | pbcopy # Copy the UDID to the clipboard since we probably want to paste it somewhere.
echo "UDID: $id"
done
fi
}
getUDID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment