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.
Written by Mustafa Paksoy
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#