←back to thread

217 points tanelpoder | 1 comments | | HN request time: 0.327s | source
Show context
mfontani ◴[] No.26494650[source]

    set -o noclobber
... works wonders to avoid this.

Sure, one may have to think and replace instances of:

    foo > bar
with:

    foo | tee bar >/dev/null
or:

    rm -f bar ; foo > bar
... but the times the "noclobber" option has _helped_ me more than makes up for the times it's been a nuisance.
replies(2): >>26494822 #>>26500015 #
1. JNRowe ◴[] No.26500015[source]
From the zsh manpage:

    >| word
    >! word
           Same as >, except that the file is truncated to 
           zero length if it exists, even if CLOBBER is unset.
Note: If you're a bash user the >| syntax is available, but not >!.