#!/bin/bash # changedefaults -- change a plist setting in 10.4.x # Written by Scott Russell, University of Notre Dame #+ with advice from Nigel Kersten, University of NSW, Australia SUCCESS=0 ERR_NOARGS=65 if [[ -z "$3" ]] ; then echo "" echo " *** Usage: `basename $0` path-to-plist find-string replacement-string" echo " *** Example: `basename $0` ~/Library/Preferences/com.apple.mail.plist CacheAllBodies CacheNoMessages" echo " *** ... replaces all instances of \"CacheAllBodies\" with \"CacheNoMessages\" in \"com.apple.mail.plist\"" echo "" exit $ERR_NOARGS else # Convert the plist from binary to xml format plutil -convert xml1 "$1" # Read the file and change old item for new item sed s/"$2"/"$3"/ "$1" > temp-file.plist mv -f temp-file.plist "$1" # Convert the plist back to binary format # plutil -convert binary1 "$1" fi exit $SUCCESS