[clue-tech] Detecting media change

David L. Willson DLWillson at TheGeek.NU
Thu May 1 14:34:18 MDT 2008


> > I guess you can just check the UUID, but I don't know how that might 
> > work for a CD.
> 
> What would be the code to get the UUID for a given dev-node?
> 
> current-UUID = $(ls -l /dev/disks/by-path | cut ... something) ?

Found it.  'blkid' is my friend.

The sed command is awful.  I'm sure it's the wrong way to do it, but it seems to have
worked.  The sed bit looks for some stuph, then 'UUID="', then some stuph that isn't the
closing quote, which it stores in a pattern buffer, then the closing quote, followed by
more stuph, and replaces everything with whatever it stored in the first pattern buffer.

blkid /dev/sda1 | sed -e 's/^.*UUID="\([^"]*\)".*$/\1/'


More information about the clue-tech mailing list