The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to know when a new file is created? aixjadoo UNIX for Dummies Questions & Answers 1 07-02-2008 12:11 PM
File created time yakyaj UNIX for Advanced & Expert Users 6 03-23-2007 09:20 AM
file was created before 15 days ago. YoungBlood UNIX for Dummies Questions & Answers 1 03-02-2007 01:23 PM
Script to check for a file, check for 2hrs. then quit mmarsh UNIX for Dummies Questions & Answers 2 09-16-2005 02:46 PM
Check lists for Unix Shell Programming srikanth_ksv Shell Programming and Scripting 2 08-08-2005 06:40 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-15-2008
velocitnitin velocitnitin is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 6
To check the lists of file created between 30-60 min

Hi

I have to write a script, that will find out the lists of files in a particular directory, which are created between 30-60 min intervals.
  #2 (permalink)  
Old 07-15-2008
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,708
use touch to create two files - one 30 minutes old and the other 60 minutes old.
Then use find with the -newer option
Code:
touch -t 200807152100 min30
touch -t 200807152130 min60
find /path/to/files -type f \( -newer min60 -a ! -newer min30 \)
  #3 (permalink)  
Old 07-15-2008
velocitnitin velocitnitin is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 6
The files are created by script, i cannot manually create the file.this script will be running after every 1 hr, so i cannot hardcode the time inthe script.
  #4 (permalink)  
Old 07-15-2008
vikas.nv vikas.nv is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 7
Here I have a perl script that does what you exactly want. As agrument pass the path you want to search for files:

use strict;
use File::Find;

my $path_to_start = $ARGV[0];
my @files_bet_30_60 = ();
my $thirty_mins_in_secs = 30*60;
my $sixty_mins_in_secs = 60*60;

finddepth(\&wanted, $path_to_start);
foreach my $file (@files_bet_30_60) {
print "$file\n";
}

sub wanted {
my $file = $File::Find::name;
next unless (-f $file);

my $mtime = (stat($file))[9];
my $time_diff = time - $mtime;
push @files_bet_30_60, $file if
(($time_diff > $thirty_mins_in_secs) && ($time_diff < $sixty_mins_in_secs));
}

Regards,
Visit my blog: techdiary-viki.blogspot.com
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:49 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0