我正在寻找一种方法来获取plist文件中指定键的所有值。 实际上,我想浏览plist文件,每次读取指定的键时,我都会将值放在数组中。
非常感谢:)
答案 0 :(得分:1)
我不确定我是否完全理解你,但这里有一个关于如何从windowserver首选项中读取所有IODisplayLocation值并创建一个applescript数组的示例。
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to ";"
set theItems to (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep IODisplayLocation | awk '{print $3}'")
set itemList to (every text item of theItems) as list
set AppleScript's text item delimiters to oldDelimiters
display dialog item 4 of itemList
答案 1 :(得分:1)
您可以尝试使用sed访问这些值。假设:
set keyValues to paragraphs of (do shell script "sed -En '/CFBundleIconFile/ {
n
s/.*>([^<]+).*/\\1/
p
}' < " & quoted form of "/Users/John/Desktop/Info.plist")