Zero bye file not deleting


 
Thread Tools Search this Thread
Top Forums Programming Zero bye file not deleting
# 1  
Old 11-14-2006
Zero bye file not deleting

Hi All...

The code i have written is

if(filename)
remove_files (filename);

and my remove function is
=========================================
void remove_files(char *rf)
{
if (remove(rf)==0)
printf("(%d) Deleting %s\n",getpid(), rf); // JC 10/24/2003
else
printf("(%d) Cannot delete %s\n",getpid(), rf);// JC 10/24/2003
}
=========================================================

The problem is if the file to be removed is a zero byte file it is not deleting . Please let me know how can i delete the zero byte file and let me know why remove is not removing zero byte file and how can i remove it ..


Thanks in advance,
Arun Kumar
# 2  
Old 11-14-2006
Do you know the filename that the error is being thrown for? If you do, just run the command:
Code:
fuser -fu "full_path_to_filename"

This will show you the pid for any process has that file open. If you do get the pid, check for that using the 'ps' command and find if you can terminate that process. The file should get deleted after you kill the process.
# 3  
Old 11-14-2006
Thanks working
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Deleting file basing on the timestamp substring in the file name

Hello, I have in my backup folder, files with names convention like this : randomFileNames_13-02-2014_23h13m09+1392333189 randomFileNames_14-02-2014_02h13m09+1392343989 randomFileNames_14-02-2014_04h13m09+1392351189 etc.... Base on timestamp at end of the filename, I would to delete all the... (7 Replies)
Discussion started by: thuyetti
7 Replies

2. Shell Programming and Scripting

Difference between exit, bye and quit in sftp

Hi All, I would like to know whether is there any difference in closing the sftp connection with exit, bye and quit. And would like to know the reliable command. (3 Replies)
Discussion started by: Girish19
3 Replies

3. UNIX for Dummies Questions & Answers

Deleting a pattern in UNIX without deleting the entire line

Hi I have a file: r58778.3|SOURCES={KEY=f665931a...,fw,221-705}|ERRORS={16_1:T,30_1:T,56_1:C,57_1:T,59_1:A,101_1:A,115:-,158_1:C,186_1:A,204:-,271_1:T,305:-,350_1:C,368_1:G,442_1:C,472_1:G,477_1:A}|SOURCE_1="Contig_1092402550638"(f665931a359e36cea0976db191ff60ff09cc816e) I want to retain... (15 Replies)
Discussion started by: Alyaa
15 Replies

4. Shell Programming and Scripting

awk - writing matching pattern to a new file and deleting it from the current file

Hello , I have comma delimited file with over 20 fileds that i need to do some validations on. I have to check if certain fields are null and then write the line containing the null field into a new file and then delete the line from the current file. Can someone tell me how i could go... (2 Replies)
Discussion started by: goddevil
2 Replies

5. UNIX for Dummies Questions & Answers

If Else Statement, Goodnight/bye

I'm working on a script that will send me an email everytime I log out. I've got that down, and now I'm trying to put in an if else statement. Right now, it says "Goodbye $USER" but I'd really like it to say Have a Great Day if it's before 4pm and Have a Good Night if it's after 4pm. So far, I have... (3 Replies)
Discussion started by: bbowers
3 Replies

6. Shell Programming and Scripting

Deleting lines inside a file without opening the file

Hi, Just consider there are around 10 lines in a file. Now is it possible to delete the first 2 lines in the file without opening the file. No matter whatever the content of the file is, I just wanna delete the first 2 lines without opening the file. Is that possible? If so, please help me out.... (3 Replies)
Discussion started by: toms
3 Replies
Login or Register to Ask a Question