Friday, October 19, 2012

Bash tips

https://github.com/wayneeseguin/rvm/blob/master/binscripts/rvm-installer

shopt -s extglob
Turn on glob pattern matching of filenames.


sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n 
Sort lines containing version numbers such as:
1.2.3
1.16.2
e.g. curl -s https://api.github.com/repos/wayneeseguin/rvm/tags |
    sed -n '/"name": / {s/^.*".*": "\(.*\)".*$/\1/; p;}' |
    sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n
typeset
Declare semi-strongly typed variables.

builtin cd
Execute "cd" - useful for redefining a function whose name is the same as a shell builtin