Skip to content

Instantly share code, notes, and snippets.

@ShawnMcCool

ShawnMcCool/.zshrc

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

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.