Linux, FreeBSD, Juniper, Cisco / Network security articles and troubleshooting guides

It is currently Sat Jan 23, 2021 9:47 am

Message body:
Enter your message here, it may contain no more than 60000 characters. 

:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:
Font size:
Font colour
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Disable BBCode
Disable smilies
Do not automatically parse URLs
Confirmation code
Confirmation code:
In an effort to prevent automatic submissions, we require that you enter both of the words displayed into the text field underneath.

Topic review - bash: -bash: output: cannot overwrite existing file
Author Message
Post subject: bash: -bash: output: cannot overwrite existing file  |  Post Posted: Mon Oct 31, 2011 7:03 am
In Bash shell, redirecting output to a existing file is not possible if the "noclobber" bash option is set.

To overcome this, use the ">|" or ">>" redirect operator. The pipe will overwrite the file if you are using single angle bracket and append if you're using double angle brackets.

How to forcely overwrite a file with output from a command:
# cat output
# echo 'output' >output
-bash: output: cannot overwrite existing file
# echo 'output' >|output
# cat output

!!! Caution: using the ">|" operator can potentially overwrite important system/configuration files !!!
Jump to:  
cronNews News Site map Site map SitemapIndex SitemapIndex RSS Feed RSS Feed Channel list Channel list

Delete all board cookies | The team | All times are UTC - 5 hours [ DST ]