Created
May 1, 2015 03:18
-
-
Save snoremac/c5aafb6eba6fb5bc1d65 to your computer and use it in GitHub Desktop.
Manage JDK symlinks on OS X
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
# Example: sudo symlink-java jdk1.8.0_40.jdk jdk1.8.0_45.jdk | |
OLD_JDK=$1 | |
NEW_JDK=$2 | |
SYMLINK_DIR=/usr/bin | |
TARGET_DIR=/Library/Java/JavaVirtualMachines/$NEW_JDK/Contents/Home/bin | |
for file in $(ls -l $SYMLINK_DIR |grep "$OLD_JDK" |awk '{ print $9 }'); do | |
if [ -n $file ]; then | |
echo "Removing $SYMLINK_DIR/$file" | |
rm $SYMLINK_DIR/$file | |
fi | |
done | |
for file in $(ls $TARGET_DIR); do | |
echo "Linking $SYMLINK_DIR/$file -> $TARGET_DIR/$file" | |
ln -s $TARGET_DIR/$file $SYMLINK_DIR/$file | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment