Unable to overwrite but can delete file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unable to overwrite but can delete file
# 1  
Old 03-01-2010
Unable to overwrite but can delete file

I'm debugging a ksh script written by someone else that does the following:

It runs a command and redirects stdout to a file called dberror that already exists using ">". This command fails with the following error:

The file access permissions do not allow the specified action.
Code:
dberror: 0403-005 Cannot create the specified file.

The script continues and a couple lines later it deletes the error file like this:
rm -f dberror

The file is successfully deleted but no file permissions are changed in the script.

My question is why the ">" operator can't overwrite the file but the rm -f can delete it? I always thought that anyone who has write permissions on the file could overwrite it with ">".

Last edited by Yogesh Sawant; 03-01-2010 at 01:40 PM.. Reason: added code tags
# 2  
Old 03-01-2010
To overwrite a file, you need write permissions on the file. To delete it, you need write permissions on the directory holding the file.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tried many options but unable to delete blank lines from text file

Hi, I tried the following options but was unable to delete blank lines from file Input file = temp.hash.txt temp.hash.txt content 90 0 89.56 0 0 57575.4544 56.89 (9 Replies)
Discussion started by: uuuunnnn
9 Replies

2. Shell Programming and Scripting

Wget download file ( do not overwrite )

Hello all, I want to write auto update script for my embedded device, which can check and download newer version of my program and extract the files on the device. The download center is hosted on remote web server . Script checks the hosted file on web site and if the new version is there... (8 Replies)
Discussion started by: stefki
8 Replies

3. Shell Programming and Scripting

Overwrite file every day

Hi Friends, I have written a script to capture system performance every hour and redirected to output file. How to overwrite the file every next day? Thanks Suresh (4 Replies)
Discussion started by: suresh3566
4 Replies

4. Shell Programming and Scripting

Better to Delete or Overwrite

Hello All, I had just a question about my Bash Script I'm currently writing. The script I have writes some text to a output file. After I write to the output file I send the file to another server to do some stuff with it. After the file sends in the script, I don't need the output/txt... (4 Replies)
Discussion started by: mrm5102
4 Replies

5. Shell Programming and Scripting

Rsync help - unable to delete the Source file

Hi All, I am facing problem deleting Source while using the rsync command. rsync --include=*`date --date="-1 day" \+\%Y\%m\%d`* --include=*`date +\%Y\%m\%d`* --exclude=* --delete-after -auvb -e ssh USER@SERVER:SOURCE DESTINATION However the sync happens but not the deletion of the source... (1 Reply)
Discussion started by: amitkhiare
1 Replies

6. UNIX for Advanced & Expert Users

Unable to delete an open file

I am working on a unix server. I killed all the processes with my id on the machine. After that I tried to delete a file, I got an error:- file not removed.Text File busy. Deletion of directory prompted:- Directory not empty. Can anyone help me regarding this...??? Thanks, Vikas (11 Replies)
Discussion started by: vikasrout
11 Replies

7. Windows & DOS: Issues & Discussions

Unable to delete a file through SAMBA

We have AIX box with a share. We have a Windows 2000 server with a mapped drive to this share. We were able to create and delete files inside the mapped drive. I removed the map. Changed it to a test share. Removed that map. Added it back to teh original share. However, now we can... (3 Replies)
Discussion started by: mcubitt
3 Replies

8. Shell Programming and Scripting

Overwrite & Delete in Text File

Dear All, I have text file like this: Header Record 1 Record 2 ....... Record n Tail This line of code : awk '{ if ( NR == 1 ) { head=substr($0,1,300);} else { last = substr($0,1,300);}END{printf "Header is : %-300s Trailer is : %-300s\n", head, last}' filename converted Header... (11 Replies)
Discussion started by: 33junaid
11 Replies

9. UNIX for Dummies Questions & Answers

unable to delete a file

Hi .. I am trying to deleta a file but i cant do the error i get is rm: hs_pdref_custom_dict_PG1_out_76_out non-existent but when i do ls it is listing the in the directory ... please find the filed below.... -rw-r----- 1 tsta107 users 118011030 Dec 1 04:07... (13 Replies)
Discussion started by: arunkumar_mca
13 Replies

10. UNIX for Dummies Questions & Answers

unable to delete file for permission problem

Hi, We are facing problem to delete some logfiles. Explaing with example for clear understanding : we have 2 accounts : prdpqrs (application account) & prodxyz (admin account - not root). Both of them are in same group called 'release' While prodxyz is trying to remove a file owned by... (4 Replies)
Discussion started by: sabyasm
4 Replies
Login or Register to Ask a Question