Software >> OS >> Unix >> Linux >> Red Hat Enterprise Linux >> How to use blkid command to check whether media is present in a CD-ROM drive

e.g. if disk is present in the drive

# blkid /dev/sr0
/dev/sr0: UUID="2013-05-31-23-04-19-00" LABEL="ARCH_201306" TYPE="iso9660" PTTYPE="dos"

# echo $?
0
 

=> If media is present, there will be some output showing the media label etc AND the value of $? will be 0


e.g. if disk is not present in the drive

# blkid /dev/sr0
# echo $?
2