Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sometimes my CD-ROM is mapped to /dev/sg0 and sometimes to /dev/sg1. How do I detect the currently mapped device in a bash script?

share|improve this question
up vote 0 down vote accepted

Assuming the cdrom is already mounted (it normally mounts automatically when a CD is inserted), just run the following command:

mount | grep ^'/dev/sg' | awk '{print $1}'
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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