Over a million developers have joined DZone.

Mounted Volumes On Mac OS X

DZone's Guide to

Mounted Volumes On Mac OS X

· ·
Free Resource
// description of your code here

# See also:
# localvols in
# http://codesnippets.joyent.com/posts/show/1888

/bin/df -l | /usr/bin/sed -E -e 1d -e 's/^([^ ]+[ ]+)[^\/]+//' | /usr/bin/sort -u
/bin/df -l | /usr/bin/sed -E -e 1d -e 's/^([^ ]+[ ]+){5}//' | /usr/bin/sort -u

/bin/df -a | /usr/bin/sed -E -e 1d -e 's/^([^ ]+[ ]+)[^\/]+//' | /usr/bin/sort -u

declare IFS=$'\n'
#for volume in $(/bin/df -l | /usr/bin/sed -E -e 1d -e 's/^([^ ]+[ ]+)[^\/]+//' | /usr/bin/sort -u); do 
for volume in $(/bin/df -a | /usr/bin/sed -E -e 1d -e 's/^([^ ]+[ ]+)[^\/]+//' | /usr/bin/sort -u); do 
   echo "vol: $volume"
declare IFS=$' \t\n'

# Cf. Get A List Of Mounted USB Drives
# http://www.adminselfhelp.com/?p=220

system_profiler SPUSBDataType | grep "BSD Name:" | awk '{gsub (" BSD Name: ","");print}'
diskutil info disk1
diskutil info disk1s3

system_profiler SPUSBDataType | sed -E -n 's/ *BSD Name: *([^ ]*)/\1/p'

declare IFS=$'\n'
for device in $(system_profiler SPUSBDataType | sed -E -n 's/ *BSD Name: *([^ ]*)/\1/p'); do
   for usbdevice in $(diskutil info "$device" | sed -E -n 's/ *Mount Point: *(.*)/\1/p' | sed '/^ *$/d'); do
      echo "USB device mounted at: ${usbdevice}"
declare IFS=$' \t\n'


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}