Last Updated: February 25, 2016
·
391
· paksoy

Prevent accidental overwrites with redirects

By default, bash output redirects, i.e. >, will clobber the contents of the target file. It's a great way to accidentally lose data without so much as a confirmation prompt. You can disable the unsafe behavior by putting this in your .bashrc:

set -o noclobber

Appends with >> will work as before. But now if you really want erase file contents you can use >| instead.