Skip to content

Instantly share code, notes, and snippets.

@jineshqa
Last active March 7, 2019 01:59
Show Gist options
  • Save jineshqa/42fbb44920e50f7f69391f5fb05350fe to your computer and use it in GitHub Desktop.
Save jineshqa/42fbb44920e50f7f69391f5fb05350fe to your computer and use it in GitHub Desktop.
How to get udid for a particular device from shell using jq

With JQ installed - output of this command is string with quotes

xcrun simctl list --json | jq '.devices["iOS 12.0"] [] | select(.name=="iPhone X") | .udid'

With JQ if you don't want quotes

xcrun simctl list --json | jq -r '.devices["iOS 12.0"] [] | select(.name=="iPhone X") | .udid'

Without JQ installed

xcrun simctl list | grep "Booted" | cut -d '(' -f2 | cut -d ')' -f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment