LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   shell script redirection -- a question (https://www.linuxquestions.org/questions/linux-software-2/shell-script-redirection-a-question-802215/)

SaintDanBert 04-15-2010 11:19 AM

shell script redirection -- a question
 
I have a script with something like the following:
Code:

echo "blah blah ... blah" >|  /my/file
NOTE -- the redirection is angle+pipe.

I've looked all over and do not find this syntax explained. I feel silly that (1) I can't find an explanation, and (2) I don't already know this.

Would someone kindly explain "echo stuff >| /myFile" redirection?

Cheers,
~~~ 0;-Dan

ilikejam 04-15-2010 11:37 AM

Hi.

The '>|' form of redirection ignores the 'noclobber' setting, so the redirection won't fail even if the target file exists.

Dave

catkin 04-15-2010 11:42 AM

The GNU bash reference explains it (and the man page is similar): "The general format for redirecting output is:

[n]>[|]word

If the redirection operator is ‘>’, and the noclobber option to the set builtin has been enabled, the redirection will fail if the file whose name results from the expansion of word exists and is a regular file. If the redirection operator is ‘>|’, or the redirection operator is ‘>’ and the noclobber option is not enabled, the redirection is attempted even if the file named by word exists
".


All times are GMT -5. The time now is 01:27 PM.