Ubuntu – Fastest way to backup a single file

backupfiles

I want to quickly create a backup of a file, by creating a duplicate with a '~' at the end, in terminal. Is there any straight forward single command way of doing this?

Best Answer

Create a shell function

backup() {
   cp ${1} ${1}~
}

Put it in your shell rc file, for bash it is ~/.bashrc. Source .bashrc or start a new shell.

 . ~/.bashrc
 backup youFile

And you have a copy of yourFile.

Related Question