is there a way to configure the shell to do not overwrite the file if it already exists? Maybe a no-clobber option?
Sim, há a opção noclobber
:
Prevent output redirection using
>
,>&
, and<>
from overwriting existing files.
$ echo foo > bar
$ echo foo > bar
$ set -o noclobber
$ echo foo > bar
bash: bar: cannot overwrite existing file