There are a couple of other methods of doing this, but this is the one that works for me.
Firstly, since system_profiler does not have the quickest of execution times, we only run it once and redirect it’s output to a static file for grepping.
1 |
system_profiler SPApplicationsDataType > temp_file |
Then we query the temp file for a list of all the software we are interested in (this is for administrative purposes only)
1 |
grep -A2 -i -E '(firefox|gimp|office):' temp_file | awk '/:$/ {printf $0}; /Version: / {print "",$2,$3}' |
Then the actual useful part
1 |
grep -A2 -i -E '(firefox):' temp_file | awk '/Version: / {print "",$2,$3}' |
If people are interested I will wrap this all up into a puppet manifest in a later post.