Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I want to mount my USB to a mount point which holds the UUID name. But I don't know how to express this in a command line!

Can someone help me how to do it?

I have searched and found that I have to run:


then a command which searches for a USB flash or hard disk drive, then something like

blkid | tail -n 1 | cut -f4 -d' '

but tail is wrong because I don't know the number of USB I have!

Is there a way to tell it to just get me the lines with USB type?

share|improve this question
here's the answer . I found it my self by trial and error: sudo blkid | tr -s ' ' | grep 'TYPE="vfat"' | cut -f4 -d'"' | sed -n "p" sed ! can't under stand it :S – Nancy Smith Mar 10 '13 at 10:17
Your sed -n "p" is redundant, it just prints what it gets unaltered, like cat. – donothingsuccessfully Mar 10 '13 at 12:20

Reading the man page shows you can use options to get what you want:

blkid -t TYPE=vfat -sUUID

gives (for me):

/dev/sdb: UUID="50CA-8C03"

You can extract the UUID with cut -d'"' -f2:

blkid -t TYPE=vfat -sUUID | cut -d'"' -f2

The blkid options are preferable because a USB drive can have e.g. a label which would give a different output of with plain blkid invocation.

EDIT: further reading of the man page shows blkid can do what you want on its own:

blkid -t TYPE=vfat -sUUID -ovalue

share|improve this answer

Your Answer


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.