- Grabbing a Mac app's icon: advanced Bash usage - Brett Terpstra
- CodeSnippets: Searching with grep & Spotlight's kMDItemDisplayName
#!/bin/sh
appname=`echo "$*" | sed 's|\.app$||'`
apppath=`mdfind -onlyin /Applications/ -onlyin ~/Applications/ -onlyin /Developer/Applications/ -onlyin /System/Library/CoreServices/ "kMDItemKind=='Application'" | grep -i "/$appname.app\$"`
bundleicon=`defaults read "$apppath/Contents/Info" CFBundleIconFile | sed 's|.icns$||'`