How can I tell what model iDevice is plugged into my USB via Terminal? This website has a useful list of the various iDevice models.  And the "identifier" column is helpful for any iOS developers, as this is the string you can fetch in your application to determine what kind of device your program is running on.

However, for reasons, I am interested in determining via Terminal what sort of devices is plugged into my OS X computer.

Using the following script in Terminal, I can grab the "version" of my device:

system_profiler SPUSBDataType | sed -n -e 's/  */ /g' -e '/iPad/,/Version/p' -e '/iPhone/,/Version/p' | grep 'iPad\|iPhone\|Version' | awk 'NR%2{printf $0;next;}1'


And for the devices I can get my hands on, these numbers somewhat line up.


My iPhone 5s gives me version 6.01 (versus "iPhone6,1").
My iPad 2 gives me version 2.40 (versus "iPad2,4").
My old iPhone 4 gives me version 3.10 (versus "iPhone3,1").


I've been able to also run this script for an iPad Mini which gave 2.50 (versus "iPad2,5").  Also, an iPad Air gave me 4.01 (versus "iPad4,1").

But that's all I've been able to test so far.  There's some correspondence between the website I linked and the results I've seen, but it's not enough that I can just build a list (6,1 to 6.01 versus 2,4 to 2.40 for example).  I need an exact matching.

Has someone compiled a complete list of these hardware versions already (I can find nothing official from Apple)?  If nothing else, it would be appreciated if people with various other devices could confirm what version number they get from that script.

As a sidenote, I only particularly care about iOS devices, but it should also be noted that I don't have an iPod to test this script with, so I have no idea whether or not iPods will show up with this exact script.
For all it's worth, I have ran the command line in Terminal with a few devices.

iPhone 4: iPhone: Version: 3.20

iPad 2: iPad: Version: 2.10

I have a 3GS somewhere but I can't find right now. I'll edit my answer if/when I find it. 

My wife has a iPhone 4S and a friend has a 5, I will try to also update once I get to run it.