Skip to content

Instantly share code, notes, and snippets.

@leoh0
Created October 31, 2015 12:20
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leoh0/d07787e9dc635136de6a to your computer and use it in GitHub Desktop.
Save leoh0/d07787e9dc635136de6a to your computer and use it in GitHub Desktop.
write access ntfs disk for mac os
#!/usr/bin/env bash
if mount | grep -q 'ntfs' ; then
if ! mount | grep -q 'read-only' ; then
echo -e "\033[01;36mExist already in /etc/fstab.\033[00m"
VOLUME=$(mount | grep "(ntfs, " | sed 's|/dev/disk[0-9]s[0-9] on \(.*\) (ntfs,.*$|\1|g')
open "$VOLUME"
exit
fi
DISK=$(mount | grep 'read-only' | awk '{print $1}')
UUID=$(diskutil info $DISK | grep UUID | awk '{print $3}')
echo -e "\033[01;36mRegistry into /etc/fstab.\033[00m"
echo "UUID=$UUID none ntfs rw,auto,nobrowse" | sudo tee -a /etc/fstab > /dev/null
diskutil umount $DISK
diskutil mount $DISK
VOLUME=$(mount | grep "(ntfs, " | sed 's|/dev/disk[0-9]s[0-9] on \(.*\) (ntfs,.*$|\1|g')
open "$VOLUME"
else
echo -e "\033[01;36mThere is no ntfs disk in here.\033[00m"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment