lhunath 1284130536 learn Find the latest modified file in a directory: latest() ( shopt -s nullglob; local file files=("${1:-.}/"*) latest=$files; for file in "${files[@]}"; do [[ $file -nt $latest ]] && latest=$file; done; printf %s "$latest" ) lhunath 1288454056 forget lhunath 1288454154 learn Find the latest modified file in a directory: latest() ( shopt -s nullglob; cd "$1"; local file latest; for file in ./*; do [[ $file -nt $latest ]] && latest=$file; done; printf %s "$latest" ) lhunath 1290506610 forget lhunath 1290506782 learn Find the latest modified file in a directory: latest() ( local file latest; for file in "$1"/*; do [[ $file -nt $latest && latest=$file; done; printf %s "$latest" ) ## Usage: latest mydir lhunath 1290506845 forget lhunath 1290506862 learn Find the latest modified file in a directory: latest() ( local file latest; for file in "${1:-.}"/*; do [[ $file -nt $latest ]] && latest=$file; done; printf %s "$latest" ) ## Usage: latest mydir greycat 1292360342 forget greycat 1292360382 learn Find the latest modified file in a directory: latest() { local file latest; for file in "${1:-.}"/*; do [[ $file -nt $latest ]] && latest=$file; done; printf '%s\n' "$latest"; } ## Usage: latest [dir] izabera 1424273126 forget izabera 1424273144 learn Find the latest modified file in a directory: latest() { local file latest; for file in "${1:-.}"/*; do [[ "$file" -nt "$latest" ]] && latest=$file; done; printf '%s\n' "$latest"; } ## Usage: latest [dir] izabera 1424273327 forget izabera 1424273336 learn Find the latest modified file in a directory: latest() { local file latest; for file in "${1:-.}"/*; do [[ $file -nt $latest ]] && latest=$file; done; printf '%s\n' "$latest"; } ## Usage: latest [dir]