I've noticed that each DVD image has a semi-unique uppercase name. Is there a standardized way for me to simply read this name as a non-root user in Linux? I'm on an Ubuntu 12.04 derivative running kernel 3.7. I'd like to simply get the name of any disk currently in the drive like so:

DVD_NAME="$( ./read-dvd-name.sh )"
  • 2
    It's bad practice to use all uppercase variable names for non-environment variables.
    – jordanm
    Jan 18 '13 at 5:02
  • 5
    Thanks, but this doesn't answer my question :) Bad-practice is debatable. Jan 18 '13 at 6:20
  • 3
    That's why it was a comment and not an answer.
    – jordanm
    Jan 18 '13 at 14:38

You could use blkid for that:

DVD_NAME=$(blkid -o value -s LABEL /dev/dvd)

(you need to have read permission to /dev/dvd for that).


DVD_NAME=$(udevadm info -n dvd -q property | sed -n 's/^ID_FS_LABEL=//p')

for which you don't need any special privilege (udev (running as root) queries the label name using blkid and updates a device database which you query with udevadm).

  • Do I need to be root to do that? Feb 1 '13 at 23:57

I am not sure whether this would help you:

isoinfo  -i C462_19-08-26_09-56.iso -d | sed -n 's/^Volume id: //p'
isoinfo  -i C462_19-08-26_09-56.iso -d | awk '/Volume id: / {print $3}'

My clumsy original solution:

dvdtitle=$(isoinfo  -i isofile.iso -d | grep "Volume id:" | awk '{print $3}')
  • 2
    (1) The question title is “Read the title from a DVD?” and the last sentence in the question says, “I’d like to simply get the name of any disk currently in the drive …”, so you should probably start off by suggesting isoinfo -i /dev/cdrom -d   …, and then add, as a postscript, the fact that the command can be used to examine an ISO image in a file by specifying …   -i iso_image_filename  .  … (Cont’d) Oct 2 '15 at 18:56
  • 2
    (Cont’d) …  (2) awk is a powerful text processing tool; you hardly ever need to use it in conjunction with another text processing tool such as grep.  Your pipeline, grep "Volume id:" | awk '{print $3}', can be simplified to awk '/Volume id: / {print $3}'.  (3) Volume IDs can be multiple words, and this print $3 approach displays only the first one.  There are ways of handling this in awk, but an easier approach is to pipe the output from isoinfo into sed -n 's/Volume id: //p'.  (4) As a sanity check, it would be better to search for /^Volume id: /. Oct 2 '15 at 18:59
  • Dear G-Man, thank you for you valuable hints. :-) Sincerely X.
    – xerostomus
    Nov 6 '19 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.