ormaaj 1334125062 learn latest() { if ! shopt -q nullglob; then trap 'shopt -u nullglob' RETURN; shopt -s nullglob; fi; local -a 'dirs=(${1-*})'; local x latest; for x in "${!dirs[@]}"; do [[ ${dirs[x]} -nt ${dirs[latest]} ]] && latest=$x; done; printf ${2+'-v' "$2"} '%s' "${dirs[latest]}"; }; latest '*.xml' 'var'; echo "$var" ormaaj 1352917655 forget ormaaj 1352917682 learn https://gist.github.com/4029356