Protecting Files From Overwriting Mistakenly
To set protection on, run the below.
set -o noclobber
To make it permanent just add to your .bashrc
echo 'set -o noclobber' >> ~/.bashrc
An example how things will work after noclobber is set.
$ echo test > testfile1 bash: testfile1: cannot overwrite existing file
To forcibly overwrite the file, just add the !, like the example below.
$ echo test >! testfile1
To unset in your current shell, just run the below.
set +o noclobber
To unset totally from every new shell (if it was added to .bashrc) just remove the setting from .bashrc.