I have written shell script which reads array from plist.
PLIST_PATH="./../Documentation/documentation.plist"
echo "PATH = $PLIST_PATH"
FILE_ARRAY=`/usr/libexec/PlistBuddy -c "print :'public-headers'" $PLIST_PATH`
Now I want to retrieve all the strings from this array but i am not able to get count from this array.
please help.
Any array from your command will return an array of the form -
sed
will remove first and last line, so with this -you will get
1 2
, which you are declaring as an array inFILE_ARRAY
which you can access as -
${FILE_ARRAY[1]}
Length of such array will be -
echo ${#FILE_ARRAY[@]}
Source of the answer
The safe way is to iterate thru the array with individual Print statements for the indexes until no key is found anymore. The script below prints the number of entries in the given array key and plist