Re: UUID of a volume
Re: UUID of a volume
- Subject: Re: UUID of a volume
- From: Christopher Stone <email@hidden>
- Date: Thu, 20 Mar 2014 05:33:02 -0500
A quick question Chris. I have read in the archives that a volume name passed to 'diskutil info' might not always return a result, and that using the disk name you see in Disk Utility, e.g. disk2s1 always works. That's what I was getting with the first shell script to pass to the second shell script. Is there a way to write the script using your simpler commands to do that?
______________________________________________________________________
Hey James,
I don't have enough experience using diskutil to confirm or deny that, but it wouldn't surprise me if there were problematic circumstances possible.
For instance you might have a network drive mounted that had the same name as one of your local drives.
I wanted to avoid 2 calls to diskutil, because that slows things up a bit - but here's a version that does just that:
------------------------------------------------------------------------------------------- tell application "Finder" to set diskList to name of disks whose name is not in {"home", "net"} set diskName to choose from list diskList default items (item 1 of diskList) set volUUID to do shell script "diskutil info `diskutil list | awk '/" & diskName & "/ { print $NF }'` | awk '/UUID/ { print $NF }'" -------------------------------------------------------------------------------------------
In the meantime, I'll try to figure out exactly what your script is doing.
That gets fun when you start fooling with sed and awk. They're mighty useful, but it takes time and effort to really start grokking their syntax. I had to buy an O'Reilly book "sed & awk", and I still rate myself as a beginner.
The code between the backticks `<code>` is executed in-place and passed to the "first" diskutil call.
The awk commands are both looking for the designated text /<text>/ and then printing the last whitespace delimited field on that line.
So the interior diskutil command finds the diskID --> passed to the exterior diskutil command which gets info for that diskID --> piped to awk which finds the line that contains 'UUID' and prints the last field which is the actual UUID value.
-- Best Regards, Chris
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden