Moving Last Downloaded File Into Current Directory

Here’s how to write a Bash function — that you can add to your Bash environment — which will save you a lot of time copying files you have downloaded from the web into your current working directory.

But First …

Step by Step

First you need to get into the directory into which you wish to move the most recently download file. There’s a good chance it will be with your other repos.

Replace YOUR-PROJECT-REPO yours.

cd repos

If you want to you remind yourself what is already in here and where you are.

ls -a 

You should see at least a .git directory in here.

Let’s do everything by “by hand” first before we put it into a function.

Use the mv command to move a specific file from ~/Downloads to here ..

Replace YOURFILE with your file name. You might have more success if you use tab completion instead of trying to remember the name of the file.

mv ~/Downloads/YOURFILE .

If it worked you will see nothing. If you see the following it means you forgot the dot . for the current directory.

mv: missing destination file operand after 'YOURFILE'
Try 'mv --help' for more information.

If that happens push the up arrow to navigate to the last command and add the dot, or you can just type it again.

Now check to see if its there.

ls -a