Last active
July 19, 2017 13:58
-
-
Save ShawnMcCool/2eb4c3c786579f168849cf54cf30e01c to your computer and use it in GitHub Desktop.
Moves the most recently modified file from the source directory to the destination directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias mvltr="~/scripts/mvltr.sh" | |
alias ltr="ls -ltr" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example usage:
$ ltr ~/Downloads
$ mvltr ~/Downloads ~/Documents/Tax