Skip to content

Instantly share code, notes, and snippets.



Last active Jul 19, 2017
What would you like to do?
Moves the most recently modified file from the source directory to the destination directory.
alias mvltr="~/scripts/"
alias ltr="ls -ltr"
if [ -z "$1" ]
echo "You must provide a directory from which to grab the newest file."
echo "\tmvltr ~/source ./destination"
exit 1
if [ -z "$2" ]
echo "You must provide a target to move the file"
echo "\tmvltr ~/source ./destination"
exit 1
lastFile=`ls -d -t $1/** | head -n1`
mv "$lastFile" "$2"

This comment has been minimized.

Copy link
Owner Author

@ShawnMcCool ShawnMcCool commented Jul 19, 2017

example usage:

$ ltr ~/Downloads
$ mvltr ~/Downloads ~/Documents/Tax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.