Avatar
Hund

# emerge life

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! ;)

Feedback

I don't have a commenting system on my blog since there's no good solutions that works without JavaScript, is user friendly and respects both the users freedom and privacy. So for now, all feedback and hellos can be done via either e-mail, XMPP or Mastodon.