Last active
April 13, 2025 23:35
-
-
Save tehnoir/312ae605068616f8d6f0 to your computer and use it in GitHub Desktop.
getudid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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