The other day I needed to find the location of an application using its bundle ID. Easy, just use LaunchServices. But I needed to do this from a script. Here are a couple perl one-liners to do it.
$ perl -MMac::Processes -e 'printf "%s\n", LSFindApplicationForInfo(undef, "com.apple.TextEdit")'/Applications/TextEdit.app$ mv /Applications/TextEdit.app ~/Desktop/ $ perl -MMac::Processes -e 'printf "%s\n", LSFindApplicationForInfo(undef, "com.apple.TextEdit")'/Users/jgm/Desktop/TextEdit.app$ mv ~/Desktop/TextEdit.app /Applications/ $ perl -MMac::Processes -e 'printf "%s\n", LSFindApplicationForInfo(undef, undef, "TextEdit.app")'/Applications/TextEdit.app
(Yes, I know mdfind could do something similar. But it wouldn’t necessarily return the one that LaunchServices thinks is the “preferred” one if there were multiple applications with the same bundle ID.)