Guides and tutorials for Red Hat Linux, Debian, Suse and others.

Advertisement


DNS query tools & Network tools (Ping & Traceroute)

Linux Shell: "Cannot overwrite existing file" when the file is owned by you

Postby LaR3 » Mon Aug 24, 2009 5:26 pm

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.
Code: Select all
# echo "2nd Overwritten content">tmp.file
bash: tmp.file: cannot overwrite existing file

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


The second option is to use the pipe (|)right after the redirection sign:
Code: Select all
# echo "2nd Overwritten content" >| tmp.file
# cat tmp.file
2nd Overwritten content
LaR3
 
Posts: 19
Joined: Mon Aug 03, 2009 11:55 pm


Advertisement


Return to Linux Distributions

Similar topics


Who is online

Users browsing this forum: No registered users and 0 guests