Recently I'm echoing short sentences to a tree_hole file.I was using echo 'something' >> tree_hole to do this job.But I was always worried of what if I mis-input of > instead of >>, since I did this often.So I made a global bash func of my own in the bashrc:function th { echo $1 >> /Users/zen1/zen/pythonstudy/tree_hole; }export -f thBut I'm wondering if there is another simple way to append lines to the end of a file.Because I may need to use that often in other occasions.Is there any?
Is there another simple way to append line to end of file other than `>>`?
bash;shell;command line;io redirection
Set the shell's noclobber option:bash-3.2$ set -o noclobberbash-3.2$ echo hello >foobash-3.2$ echo hello >foobash: foo: cannot overwrite existing filebash-3.2$ 