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

It is currently Mon Jul 06, 2020 8:01 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 - Linux Shell: "Cannot overwrite existing file" when the file is owned by you
Author Message
Post subject: Linux Shell: "Cannot overwrite existing file" when the file is owned by you  |  Post Posted: Mon Aug 24, 2009 10:26 am
If the shell noclobber environment variable is set, you will not be able to overwrite a file's content by redirecting some output to it.
# echo "2nd Overwritten content">tmp.file
bash: tmp.file: cannot overwrite existing file

First option would be to disable the noclobber variable:
# set +o noclobber; set -o | grep nocl
noclobber       off

The second option is to use the pipe (|)right after the redirection sign:
# echo "2nd Overwritten content" >| tmp.file
# cat tmp.file
2nd Overwritten content
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 ]