Swapping two files with a quick bash function

One thing I find myself doing a lot is swapping two files in bash. I thought about making this into a bash script then I realized 1) that’s over kill and 2) not as portable as I want. So, if you add this to your .bashrc then re-source it, you’ll be able to run the command swap to switch two files

function swap() {
     mv "$1" "/tmp/$TMP_NAME" && mv "$2" "$1" && mv "/tmp/$TMP_NAME" "$2"
This entry was posted in Computers, Linux and tagged , , , , . Bookmark the permalink.