# for PlistBuddy see: http://codesnippets.joyent.com/posts/show/1484 # list Safari cookies function lsc() { /usr/libexec/PlistBuddy -c print ~/Library/Cookies/Cookies.plist | \ /usr/bin/awk '/^[[:space:]]+Domain = /{sub( /^[[:space:]]+Domain =[[:space:]]+/,""); print}' | \ /usr/bin/sort -u | /usr/bin/nl #/usr/bin/awk '!x[$0]++' | /usr/bin/sed -n '1!G;h;$p' | /usr/bin/nl return 0 } lsc # delete Safari cookies except ... # ... for those domains specified by an egrep regex /usr/libexec/PlistBuddy -c Print ~/Library/Cookies/Cookies.plist /usr/libexec/PlistBuddy -c 'Print :0' ~/Library/Cookies/Cookies.plist /usr/libexec/PlistBuddy -c 'Print :1' ~/Library/Cookies/Cookies.plist function dsce() { declare array_indices cookiesplistfile index regex regex="${1:-$'\777'}" # delete all cookies if there is no argument $1; for \777 see man ruby cookiesplistfile="${HOME}/Library/Cookies/Cookies.plist" array_indices="$(/usr/libexec/PlistBuddy -c print "${cookiesplistfile}" | /usr/bin/awk '/Domain = /{x++;print x-1,$0}' | \ /usr/bin/egrep -iv "${regex}" | /usr/bin/awk '{print $1}' | /usr/bin/sort -rn)" :<<-'COMMENT' # test for index in ${array_indices}; do echo $index; #/usr/libexec/PlistBuddy -c "Print :'${index}'" "${cookiesplistfile}" /usr/libexec/PlistBuddy -c "Print :'${index}':Domain" "${cookiesplistfile}" done COMMENT for index in ${array_indices}; do /usr/libexec/PlistBuddy -c "Delete :'${index}'" "${cookiesplistfile}" done /usr/libexec/PlistBuddy -c save "${cookiesplistfile}" &>/dev/null return 0 } lsc dsce 'xxx.com|xxx.org' lsc
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
List & delete Safari cookies (See related posts)
Comments on this post
<h1>hermes Faux Crocodile handbag</h1>
<h1>hermes Passport Holder handbag</h1>
<h1>hermes Picotin Herpicot handbag</h1>
<h1>hermes Steve Clemence handbag</h1>
<h1>hermes Bangle</h1>
You need to create an account or log in to post comments to this site.
Related Posts
» List & delete Safari history in shell osx mac bash unix safari delete list plistbuddy plist history
» Using PlistBuddy to customiz... in shell osx mac launchd bash unix defaults launchctl plistbuddy syslogd plist
» Listing Dock items with Plis... in shell osx mac bash unix plistbuddy plist dock
» app2dock in shell osx mac bash unix database update sed add remove plistbuddy plist launch lsregister dock rebuild services
» Find broken symbolic links in find shell osx mac bash unix linux delete ls link list symlink symbolic prune
» Delete WebKit search fields in shell osx mac bash unix safari webkit
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails