Have you ever destroyed a file accidentally? If you set the noclobber C shell variable, or the noclobber option in bash and ksh , it can help you avoid these mistakes. Setting noclobber prevents you from destroying a file when you are .
Consider the following situation:
The command above destroys the old
and creates a new
one. If you have misspelled the name of your output file, or if you
have forgotten that the file already exists and contains important
data, or (most common) if you really meant to type
Setting the variable
prevents this problem. If
exists, the C shell will not allow I/O redirection to
destroy an existing file, unless you explicitly tell it to by adding an
exclamation point (
Be sure to put space after the
Remember that noclobber is not an environment variable, so any new shells you create. Therefore, if you want this feature, put the set command (above) in your shell's .
The C shell noclobber variable has one other feature that's worth noting. Normally, the C shell lets you append to a file that doesn't exist. If noclobber is set under csh and tcsh , it won't; you can only append to files that already exist unless you use an exclamation point: