I think it would be a little safer to do it this way-
diskutil list | awk '/Apple_Boot/{print $NF}'
A Recovery HD, if present, will always show up as a type of 'Apple_Boot', regardless of what it got named, so using awk's regex matching to look for that should be safe unless you somehow have more than one Recovery HD present, which would be a very unusual case. Also, telling awk to print out the last column would be safer than trying to tail the last 8 characters. Although the identifier should be 7 characters in length, there's no absolute guarantee that it will be.
Perhaps not. Check out my Fusion drive...
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.0 TB disk0
1: EFI 209.7 MB disk0s1
2: Apple_CoreStorage 999.3 GB disk0s2
3: Apple_Boot Boot OS X 650.0 MB disk0s3
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *121.3 GB disk1
1: EFI 209.7 MB disk1s1
2: Apple_CoreStorage 121.0 GB disk1s2
3: Apple_Boot Boot OS X 134.2 MB disk1s3
So, the approach fails for a different reason - it wont' be Apple_Boot until I MAKE it Apple_Boot; that's half of what the script does (the first half is to unmount). I do agree with your "last column" idea, though. I'm testing this now:
diskutil list | grep 'Apple_HFS Recovery HD' | awk '{print $NF}'
Because after imaging, it's going to look like this:
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.0 TB disk0
1: EFI 209.7 MB disk0s1
2: Apple_CoreStorage 999.3 GB disk0s2
3: Apple_Boot Boot OS X 650.0 MB disk0s3
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *121.3 GB disk1
1: EFI 209.7 MB disk1s1
2: Apple_CoreStorage 121.0 GB disk1s2
3: Apple_Boot Boot OS X 134.2 MB disk1s3
/dev/disk2
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.1 TB disk2
1: EFI 209.7 MB disk2s1
2: Apple_HFS Macintosh HD 1.1 TB disk2s2
3: Apple_HFS Recovery HD 814.6 MB disk2s3
So, this approach is targeted to exactly what I'm trying to solve: A Recovery HD that I've created from my image.
Ah, I got it now. I didn't really understand what you were trying to do in grabbing that information. I thought you needed get the disk identifier for an existing, working Recovery HD, but makes sense now. :)
Josh, do you mind sharing your final script for unmounting the Recovery HD on a Fusion drive?