#!/bin/sh # if we got a directory as first param, cd there first: if [ -d "$1" ]; then cd "$1" fi # probably GNU-dependent # list (A)lmost all files in # current dir, sorted by (t)ime, # and return the first (newest): basename=`ls -At | head -1` # get full path: readlink -f "$basename"