Sponsored Content
Top Forums Programming How to watch for file creation/deletion? Post 302145115 by blowtorch on Monday 12th of November 2007 11:33:56 PM
Old 11-13-2007
Why not just readdir? Maintain a list of files you get each time and a new file is one that you get in readdir, but not in your list. Of course, if your directory is going to have thousands of files, it isn't a good idea.

@Porter,
Won't the directory modification time change when a file is deleted as well?

Perhaps a program that checks for dir modified time and checks against a maintained a list of files if the mtime has changed...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Deletion of File in Unix

Hi there guys. I'm quite new in using unix and just recently experienced missing file problem. Someone accidentally or likely intentionally deleted one specific folders that contains important file. Now my question is, can any other user aside from root can do such action? Please help. ... (2 Replies)
Discussion started by: rhomel101
2 Replies

2. UNIX for Dummies Questions & Answers

large file deletion

OS: Solaris 8 I deleted a large file (around 13 Gigs) from my system. But the output of df -k remains the same. The capacity % is constant. However one strange thing is happening- My available space is decreasing, my used space in increasing (The opposite should happen). This is happening... (2 Replies)
Discussion started by: run_time_error
2 Replies

3. UNIX for Dummies Questions & Answers

file deletion problem

I am using unix via telnet ssh and i have a problem I was testing the server. I made a directory. Transfered a file from an ftp to it. Opened the file with the vi text editor --This where my problem came..... I tried deleting the file using rm somefile.htm when is typed ls i noticed that... (2 Replies)
Discussion started by: shdwsclan
2 Replies

4. Shell Programming and Scripting

Prompting for file deletion?

I got help in another forum but now I need further help so I figured I'd ask here. I had to write a script to delete certain filenames of certain size. I got this far.. find . -size 110c -name "*testing*" -print | xargs -n 1 rm -i It finds the correct files, but the prompts to delete are all... (2 Replies)
Discussion started by: NycUnxer
2 Replies

5. UNIX for Dummies Questions & Answers

Watch for File on Windows share using Shell Script

I want to poll a particular file on a Windows shared drive using shell script and copy it to a Unix directory if present. Step wise execution: 1) Poll/watch for a file in the following location on Windows share: (SRC_DIR=\\mum\dharmesh\research\ST_DXR_20080821 to DXR.xls) 2) If present,... (1 Reply)
Discussion started by: dharam_v
1 Replies

6. UNIX for Dummies Questions & Answers

Watch and copy a file

I need to write a simple shell script to watch a file in a directory and copy immedietly any files in that directory to another oldfiles directory once and later in the evening delete the file from the original directory. File A arrives in dir1 at 8.00AM Watch the file in dir1 and copy the file... (2 Replies)
Discussion started by: cravie
2 Replies

7. Shell Programming and Scripting

want file to regenerate after deletion

I looked into the sticky bit, but I think, if possible, that I would prefer to have the file recreate itself after deletion. The file is several directories deep, and from time to time the top level directory will be trashed. I need the file to recreate after this. Is it possible to perhaps... (13 Replies)
Discussion started by: glev2005
13 Replies

8. Shell Programming and Scripting

File content deletion

Hi Everyone, There are certain files under a folder 'ABC' and the entries for these files are there in another file(fname) under a different folder 'XYZ'. I want to compare the folder contents(ABC) with the file(fname) contents and delete the mismatching / non-existing ones from the file,... (4 Replies)
Discussion started by: swasid
4 Replies

9. Shell Programming and Scripting

Notification of user id creation/deletion

Can someone help me with a shell script that will send an email to a set of email ids when a user id is created or deleted on AIX system. Also, if the script can let the admin know when a particular user id's password will expire. (2 Replies)
Discussion started by: ggayathri
2 Replies

10. Emergency UNIX and Linux Support

User id creation/deletion - notification

Can someone help me with a shell script that will send an email to a set of email ids when a user id is created or deleted on AIX system. Also, if the script can let the admin know when a particular user id's password will expire. (4 Replies)
Discussion started by: ggayathri
4 Replies
READDIR(3)						     Linux Programmer's Manual							READDIR(3)

NAME
readdir - read a directory SYNOPSIS
#include <sys/types.h> #include <dirent.h> struct dirent *readdir(DIR *dir); DESCRIPTION
The readdir() function returns a pointer to a dirent structure representing the next directory entry in the directory stream pointed to by dir. It returns NULL on reaching the end-of-file or if an error occurred. According to POSIX, the dirent structure contains a field char d_name[] of unspecified size, with at most NAME_MAX characters preceding the terminating null character. Use of other fields will harm the portability of your programs. POSIX-2001 also documents the field ino_t d_ino as an XSI extension. The data returned by readdir() may be overwritten by subsequent calls to readdir() for the same directory stream. RETURN VALUE
The readdir() function returns a pointer to a dirent structure, or NULL if an error occurs or end-of-file is reached. ERRORS
EBADF Invalid directory stream descriptor dir. CONFORMING TO
SVID 3, POSIX, BSD 4.3 SEE ALSO
read(2), closedir(3), dirfd(3), opendir(3), rewinddir(3), scandir(3), seekdir(3), telldir(3) 1996-04-22 READDIR(3)
All times are GMT -4. The time now is 02:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy