Skip to content

Instantly share code, notes, and snippets.

@aji
Created February 27, 2012 00:40
Show Gist options
  • Save aji/1920115 to your computer and use it in GitHub Desktop.
Save aji/1920115 to your computer and use it in GitHub Desktop.
lastdl -- shell script to report the newest file in the downloads folder
#!/bin/sh
# echoes the full path of the newest download
# usage: lastdl.sh [NN], where 1<=NN<100
# adjust this appropriately:
DOWNLOADS=$HOME/Downloads
# this is horrendous
back=$1
case $back in
[0-9]|[0-9][0-9]) ;;
*) back=1 ;;
esac
file=`ls -1t $DOWNLOADS | head -$back | tail -1`
echo $DOWNLOADS/$file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment