Linux, plaintext & minimalism

How to copy and move files in your shell the safe way

There’s a saying that it’s sometimes hard to see the forest for the trees. The flag -i, --interactive for the commands cp and mv is one of those occurrences.

It has been lurking in front of my face for all these years and yet I took me forever before noticing it. The flag simply makes cp and mv ask for confirmation before they overwrite any files or folders. Like this:

$ touch {dog.txt,cat.txt}
$ mv -i dog.txt cat.txt
mv: overwrite 'cat.txt'?

This flag have actually saved me a few times. I highly recommend adding aliases for them so you never forget to use the flags:

cp='cp -i'
mv='mv -i'

You’re welcome! ;)