O'Reilly logo

A Practical Guide to Red Hat® Linux® 8 by Mark G. Sobell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

noclobber: Avoids Overwriting Files

Setting the noclobber variable prevents you from accidentally overwriting a file when you redirect output to the file. To override noclobber, put a pipe symbol after the symbol you use for redirecting or appending output (for example >| and >>|).

In the following example the user creates or overwrites a file named a by redirecting the output of date to the file. Next, the user sets the noclobber variable and tries redirecting output to a again. The shell returns an error message. Then the user tries the same thing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required