- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- I need to replace a file when it exists
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 01:39 PM
тАО09-28-2007 01:39 PM
my user is using .cshrc
if there is a file created and if i want to replace it appears the following:
unix1: cat > test
test: File exists.
how can i avoid it? it does not mind if it exists, it has to be replaced.
how can i avoid it?
please let me know.
Regards.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 01:56 PM
тАО09-28-2007 01:56 PM
Re: I need to replace a file when it exists
Do an ls -l test
Is it a directory?
What is the mode?
I could not quickly reproduce the exact message, but here is a similar situation:
$ cat > x
blah blah
$ cat > x
this works
$ mkdir x
mkdir: cannot create x: File exists
hth,
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 02:06 PM
тАО09-28-2007 02:06 PM
Re: I need to replace a file when it exists
this is the way it is working:
server1 38: ls -l test
test not found
server1 39: cat > test
bla bla
server1 40: ls -l test
-rw-rw-rw- 1 user1 sapsys2 9 Sep 28 22:04 test
server1 41: cat > test
test: File exists.
server1 42:
what do i have to modify into .cshrc for user1 can replace files when i a script is using ">" .
thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 03:40 PM
тАО09-28-2007 03:40 PM
Solution>!test
Someone has set this option in your environment, perhaps in /etc/cshrc or your .cshrc file.
In POSIX shells, you override noclobhber with | rather than ! but otherwise, the form is the same. Most script writers find this behavior annoying and unexpected when noclobber has been set.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 07:03 PM
тАО09-28-2007 07:03 PM
Re: I need to replace a file when it exists
Besides Bill's noclobber solution, you can just remove the file first:
% rm -f test
% cat > test
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 10:42 PM
тАО09-28-2007 10:42 PM
Re: I need to replace a file when it exists
Don't name a script (or any file) "test". This can create ambiguous situations for the shell which has a built-in 'test' or for that matter with the '/usr/bin/test' command!
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 11:54 PM
тАО09-28-2007 11:54 PM
Re: I need to replace a file when it exists
Yes, I've had that happen with executables. :-(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-29-2007 07:43 PM
тАО09-29-2007 07:43 PM
Re: I need to replace a file when it exists
remembering one of your last posts, I guess we have to to with a CSH.
There is a variable 'noclobber', which controls the behavior in cases, where a redirection would overwrite an existing file.
Additionally there is another redirection symbol, which ignores an existing file.
% touch hu
% cat >hu
hu: File exists
% echo a >&hu # works
% set noclobber
% echo b >hu # works as well
mfG Peter