中秋节闲来无事,顺手写了个脚本。
#!/bin/sh

if [ -z $1 ];then

  echo "usage:"

  echo "$0 disk_name"

  exit

fi

if [ -d /Volumes/$1 ];then

  echo "Do you really want to umount /Volumes/$1?[Y/n]"

  read a

  if [ "$a" != "Y" ];then

    exit

  else

  sudo umount /Volumes/$1

  fi

fi

MOUNTDIR=~/Desktop/$1

if [ ! -d $MOUNTDIR ];then

  mkdir $MOUNTDIR

fi

DISK=`diskutil list | grep "$1" | awk '{printf $6;}'`

DEVDISK=/dev/$DISK

sudo mount -t ntfs -o rw,auto,nobrowse $DEVDISK ~/Desktop/$1

echo "finished mount ntfs disk $DEVDISK"

08-31 00:26