Skip to content

Instantly share code, notes, and snippets.

@jonas8
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save jonas8/e949a5e7f24f9af8b80f to your computer and use it in GitHub Desktop.

Select an option

Save jonas8/e949a5e7f24f9af8b80f to your computer and use it in GitHub Desktop.
NTFS Read/write
#!/bin/bash
# description:
# This script use to mount readable/writable NTFS driver
usage() {
echo "usage: `basename $0` m|u volume name"
}
if [ $# -ne 2 ]; then
usage
exit 1
fi
case $1 in
m)
devinfo=$(diskutil info "$2" | awk '{if(NR==2) print}' | awk -F: '{sub(/^[[:blank:]]*/,"",$2);sub(/[[:blank:]]*$/,"",$2);print $2;}')
if [[ -z $devinfo ]]; then
echo "$2 can not be mount."
exit 1
fi
$(sudo umount "/Volumes/$2" > /dev/null 2>&1)
$(sudo mkdir "/Volumes/$2")
$(sudo mount -t ntfs -o nobrowse,rw $devinfo "/Volumes/$2")
$(open "/Volumes/$2")
;;
u)
$(sudo umount "/Volumes/$2")
;;
*) usage
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment