Skip to content

Instantly share code, notes, and snippets.

@rmanly
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmanly/11270563 to your computer and use it in GitHub Desktop.
Save rmanly/11270563 to your computer and use it in GitHub Desktop.
build array with brace expansion per Allister's recomendation
#!/bin/bash
# build array with brace expansion per Allister's recomendation
array=(/Applications/{GarageBand,Pages,iMovie,iPhoto,Keynote,Numbers}.app)
for path in "${array[@]}"; do
app_name="${path##*/}"
name="${app_name%.*}"
version=$(defaults read "${path}"/Contents/Info CFBundleShortVersionString)
pkgbuild --component "${path}" $HOME/Desktop/"${name}-${version}".pkg
done
@arubdesu
Copy link

If this were code golf...
array=(/Applications/{GarageBand,Pages,iMovie,iPhoto,Keynote,Numbers}.app) can generate multiple lines with the 'prefix' and 'suffix' you need...

@rmanly
Copy link
Author

rmanly commented Apr 25, 2014

Ah yes!

Well done. :)

In the original I was using iTerm interactively and just dragged them into place. This is much better for the full script and I probably would not have thought to use brace expansion for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment