Last active
August 29, 2015 14:00
-
-
Save rmanly/11270563 to your computer and use it in GitHub Desktop.
build array with brace expansion per Allister's recomendation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
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
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...