Comparing PHP version numbers using Bash?

Here’s how to compare versions. using sort -V: function version_gt() { test “$(printf ‘%s\n’ “$@” | sort -V | head -n 1)” != “$1”; } example usage: first_version=5.100.2 second_version=5.1.2 if version_gt $first_version $second_version; then echo “$first_version is greater than $second_version !” fi pro: solid way to compare fancy version strings: support any length of sub-parts … Read more

How to read plist information (bundle id) from a shell script

The defaults command can read/write to any plist file, just give it a path minus the .plist extension: $ defaults read /Applications/ CFBundleIdentifier This pulls the CFBundleIdentifier value directly from the application bundle’s Info.plist file. Defaults also works with binary plists without any extra steps.

Terminal: Where is the shell start-up file?

You’re probably using bash so just add these 3 lines to ~/.bash_profile: $ cat >> ~/.bash_profile export WORKON_HOME=$HOME/.virtualenvs export PROJECT_HOME=$HOME/directory-you-do-development-in source /usr/local/bin/ ^D where ^D means you type Control+D (EOF). Then either close your terminal window and open a new one, or you can “reload” your .bash_profile like this: $ source ~/.bash_profile