我已经编写了从 plist 中读取数组的 shell 脚本。
PLIST_PATH="./../Documentation/documentation.plist"
echo "PATH = $PLIST_PATH"
FILE_ARRAY=`/usr/libexec/PlistBuddy -c "print :'public-headers'" $PLIST_PATH`
现在我想从这个数组中检索所有字符串,但我无法从这个数组中获取计数。
请帮忙。
最佳答案
安全的方法是使用索引的单独 Print 语句遍历数组,直到再也找不到键为止。 下面的脚本打印给定数组键和 plist 中的条目数
PLISTBUDDY="/usr/libexec/PlistBuddy -c"
if [ "$#" -ne 2 ]; then
echo "usage: $0 <array key> <plistfile>"
exit 1
fi
KEY=$1
PLIST=$2
i=0
while true ; do
$PLISTBUDDY "Print :$KEY:$i" "$PLIST" >/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echo $i
break
fi
i=$(($i + 1))
done
关于ios - 通过shell脚本plist buddy从plist读取数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23518370/