Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Process last created directory

Status
Not open for further replies.
Joined
Jun 3, 2007
Messages
84
Location
US
Hello everyone,

Hoping someone could point me in the right direction. I am trying to write a script that will process files on the newest/latest created directory. I have a script that will process a directory based on an argument that is passed against. Since a new directory is created every so often I thought the best way to go about this would be to have the script run against the last directory that was created. I am not sure what the best way would be to go about this is? One way that I was thinking of doing it was by running a system command of "ls -tr $DIR_PATH |tail -n 1" but I know there is a a better way to do this. What is the best way to monitor a directory for new directories being created?

Just as an example: I would be monitoring the /user01/mon_dir directory once I see a new directory is created within mon_dir I would like to process that directory.

thanks for the help.
 
why not just keep a list of directories that have been processed and compare that to the actual directory? Look at the opendir and readdir commands.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top