Last active
December 22, 2015 03:39
-
-
Save somian/6411774 to your computer and use it in GitHub Desktop.
shell pipeline to get a suffiently safe filename from a disk volume LABEL as a mount point (directory name) to mount a hotplugged device.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blkid -s TYPE|egrep vfat | | |
cut -d \: -f 1| | |
xargs /sbin/blkid -c value| | |
xargs perl -MFile::Util="" \ | |
-e '$it=File::Util->new();' \ | |
-e 'print for map{/LABEL=([^=]+)(?=[[:space:]][[:upper:]]+[=])*/;' \ | |
-e '($1 ? do{($_=$it->escape_filename($1))=~s{[[:space:]]}{_}g and qq[/media/byLABELISH/$_\n]}' \ | |
-e ' : q[])} grep {LABEL} @ARGV' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I purchased a USB hard disk storage device which had been formatted with a fat32 filesystem labelled "SP PHD U3". (Silicon Power).
We get a mount point that is like: /media/byLABELISH/SP_PHD_U3