In computing, clobbering is the act of overwriting a resource such as a file, processor register or a region of memory, such that its content is lost. Generally, the term is used in the context of unintentional loss of information, but it can be used for intentional overwriting as well. The Jargon File defines clobbering as
The term originated in pottery, where clobbering is a traditional term for the deceptive and fraudulent later addition of decoration to an originally plain piece. This was especially done to Chinese porcelain, but also European wares.
In many shells, the <code>></code> file redirection operator clobbers if the output path refers to an existing file. This can be prevented in bash and ksh via the command <code>set -o noclobber</code> and in csh and tcsh via <code>set noclobber</code>. Subsequently, attempting to clobber via redirection fails with an error message. For example:
The default behavior of the <code>mv</code> and <code>cp</code> commands is to clobber an existing destination file. This behavior may be overridden via the <code>-i</code> option which results in prompting the user to confirm clobbering a file. Alternatively, the <code>-n</code> option selects to skip operations that would clobber.
A commonly used <code>make</code> target, named clobber, performs a complete cleanup of files and directories produced via previous invocations of the command for a particular makefile. It is a more thorough cleanup operation than clean and is commonly used to uninstall software. Some make-related commands invoke during their execution. They check the CLOBBER environment variable. If it is set to OFF then clobbering is not done.
In assembler programming (including GCC inline assembly) a clobbered register denotes a register whose value may be overwritten in the course of executing an instruction.