How to read multiple values at once from plist files using "defaults" in MAC OSX

1.8k Views Asked by At

I have a plist file which contains keys like

Area
Name
City
Country

As per defaults man page one can read a key from plist like this

defaults read plist-file key

E.g.

defaults read abc.plist Area 

However I want to read more than one key using defaults.

defaults read abc.plist Area City Country

The above produces output only of Area, not of City and Country.

Can anyone please suggest how can I read multiple keys from plist in one go using defaults only?

2

There are 2 best solutions below

3
am449 On

You can use

defaults read path/to/your plist
0
Armali On

Can anyone please suggest how can I read multiple keys from plist in one go using defaults only?

You can use a for loop:

for key in Area City Country; do defaults read abc.plist $key; done