Skip to content

Instantly share code, notes, and snippets.

@claudiodangelis
Created June 28, 2013 12:58
Show Gist options
  • Save claudiodangelis/5884486 to your computer and use it in GitHub Desktop.
Save claudiodangelis/5884486 to your computer and use it in GitHub Desktop.
#!/bin/sh
# -m mountpoint
# -d device
while getopts ":d:m:" opt
do
case $opt in
d)
DEVICE_TMP=$(ls /dev/disk/by-label/* | sed 's/ /\n/g'\
| grep "$OPTARG")
if [ "$DEVICE_TMP" != "" ]; then
DEVICE="/dev/"$(readlink $DEVICE_TMP | sed 's/..\///g')
echo $DEVICE
fi
;;
m)
DEVICE_TMP=$(ls /dev/disk/by-label/* | sed 's/ /\n/g'\
| grep "$OPTARG")
if [ "$DEVICE_TMP" != "" ]; then
DEVICE="/dev/"$(readlink $DEVICE_TMP | sed 's/..\///g')
MOUNTPOINT=$(mount | grep -i "$DEVICE" | awk '{print $3}')
echo $MOUNTPOINT
fi
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment