How to move your most recent file from Downloads to your current working directory
How many times did you have to navigate to the Downloads folder and move the file to your target directory. Well, I am tired doing it, so automating it.
- Create a bash script, in my case I named it to
mvd
- paste the following [1]
#!/bin/sh filename=$(find /home/mohan/Downloads -type f -printf "%T@ %p\n" | sort -n | cut -d' ' -f 2- | tail -n 1) mv $filename .
- paste the following [1]
- Give execute permission to the file
chmod +x mvd
- Add the location containing this script to the
.bashrc
file ->export PATH=$PATH:/home/user/yourfoldername/
so that you can basically call it from anywhere.
That’s it folks! Enjoy!