Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

saqibjaan

macrumors member
Original poster
Feb 1, 2012
48
1
Lahore
Here is the History.plist of Safari browser. I want to read only 2 specific values from this plist file. (www.yahoo.com AND lastVisitedDate).
How can I do it ? Kindly help.

?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>WebHistoryDates</key>
<array>
<dict>
<key></key>
<string>http://www.yahoo.com/</string>
<key>D</key>
<array>
<integer>1</integer>
</array>
<key>lastVisitedDate</key>
<string>368300984.8</string>
<key>title</key>
<string>Yahoo!</string>
<key>visitCount</key>
<integer>1</integer>
</dict>
 
Code:
PLIST_BUDDY="/usr/libexec/PlistBuddy"
THE_PLIST="$HOME/Library/Safari/History.plist"

"$PLIST_BUDDY" -c "print :WebHistoryDates:0" "$THE_PLIST" \
 | awk '($1 == "=")  { url = $2 }
  /lastVisitedDate/ { print $3, url }'

You may need to revise it, depending on your OS version.

Also see this thread for more info.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.