What is the difference between the following two redirection commands?
ls > out
ls >| out
They both seem to produce the same output.
According to [1] the difference is that >|
redirects the output to a file even if noclobber option is set.
noclobber option is set by bash's command line option -C
and prevents overwriting of files by redirection [2]. When the noclobber option is set, then ls >| out
overwrittes the file out
, while ls > out
does not.
[1] http://tldp.org/LDP/abs/html/special-chars.html
[2] http://tldp.org/LDP/abs/html/options.html#NOCLOBBERREF