Sponsored Content
Top Forums Shell Programming and Scripting Find files modified in last hour sunOS 5.10 Post 302436860 by rich@ardz on Tuesday 13th of July 2010 10:21:57 AM
Old 07-13-2010
non whatsoever, just wondering if it can be accomplished in shell Smilie

---------- Post updated at 03:21 PM ---------- Previous update was at 03:15 PM ----------

Code:
#!/usr/bin/ksh

# perl -MFile::Find -le'
  # find { 
    # wanted => sub {
      # -f and 1 >= -M and print $File::Find::name;
      # }
    # }, shift    
  # ' <dirname>
  
LOGS=/export/home/richard/share
  
  filetime()  # create a filetime x hours ago
{
perl -e '      
      $mtime = time - (3600 * $ARGV[0]);

      # time structure into variables

      ($sec,$min,$hr,$day,$mon,$yr,$wday,@dntcare) = localtime($mtime);
      $yr = ($yr>=70) ? $yr+1900 : $yr+2000;
      $mon += 1;
      printf ("%d%02d%02d%02d%02d", $yr,$mon,$day,$hr,$min); ' "$1"
}
# get file time in YYYYMMddhhmm format
oldtime=$(filetime 1)

touch -t $oldtime dummy

find $LOGS -newer dummy -print

-bash: ./perl.ksh: /usr/bin/ksh^M: bad interpreter: No such file or directory
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl find directory only if modified in last hour

I want a one liner perl command to find a directory only if the modified time is within the last hour I am running this on windows - and I will define a variable for the result. So for example I want to return value of 1 for the variable if the modified time of d:\test1 is within the last... (0 Replies)
Discussion started by: frustrated1
0 Replies

2. Shell Programming and Scripting

find files modified more than a day

Hi All, I am using the below command to check the files modified within last 24hours find /home/karthik -mtime -1 -type f -exec ls -l {} \; What parameter do i need to add in the above command to check the files modified in last 2 or 3 days Kindly let me know if any other alternative... (2 Replies)
Discussion started by: karthikn7974
2 Replies

3. Shell Programming and Scripting

help: find and modified files script

hello all im a newbie in the linux world ..i have just started creating basic scripts in linux ..i am using rhel 5 ..the thing is i wanted to create a find script where i could find the last modified file and directory in the directory given as input by the user and storing the output in a file so... (6 Replies)
Discussion started by: tarunicon
6 Replies

4. UNIX for Dummies Questions & Answers

how to find the modified files before 60 mins?

hi, I need to find all the modified files before 60 minutes in a folder. Is that possible to find using mtime in minutes? Suggestions please. Thanks for looking into it... Geetha (8 Replies)
Discussion started by: iamgeethuj
8 Replies

5. UNIX for Dummies Questions & Answers

Find last modified date for many files

Hello all - I've looked and have not been able to find a "find" command that will list the last modified date of files within a specific directory and its subdirectories. If anyone knows of such a command it would be very much appreciated! If possible, I would like to sort this output and have... (5 Replies)
Discussion started by: MichaelH3947
5 Replies

6. UNIX for Dummies Questions & Answers

HP UNIX: How to find files which are older than one hour.

HP Unix Version: HP-UX B.11.31 U ia64 Question I look for script or command to find files which are older than one hour. Tried below; # set the file time to 1 hours ago touch -t 201307160700 ./touchfile find /app/grid/product/11.2.0.3/rdbms/audit -name '*.aud' -type f ! -newer... (4 Replies)
Discussion started by: Siva SQL
4 Replies

7. Shell Programming and Scripting

List last 1 hour files with out FIND command

Hi Friends, Can we have an alternate command to list last 1hour files with out FIND command? Thanks Suresh (6 Replies)
Discussion started by: suresh3566
6 Replies

8. Shell Programming and Scripting

How to find the files created within one hour in Solaris?

Hi Gurus, I want to find the file created within one hour in solaris. I have tried below command, but it is no lucky. $find . -mtime -1/24, -name "abc*" above command give me the file name which created two hours ago find . -cmin -60, -name "abc*" above command I got error as... (4 Replies)
Discussion started by: ken6503
4 Replies

9. UNIX for Advanced & Expert Users

Find files modified in previous minute only

Hi, How can I get files which are modified only in last minute ? it should not display 2 minutes back filels -la -rw-rw-r-- 1 stuser st 51 Dec 3 09:22 a.csv -rw-rw-r-- 1 stiser st 50 Dec 3 09:25 b.csv -rw-rw-r-- 1 stuser st 53 Dec 3 09:33 c.csv When I run command at 9:34am then I... (7 Replies)
Discussion started by: sbjv
7 Replies

10. Shell Programming and Scripting

Command to find files older than 1 hour

Hi, Out of a list of files in a directory, I want to find the files which were created/modified more than 1 hour ago. I am using HP -UNIX and it does not support the argument -mmin. Please advise. I am using # !/bin/sh (4 Replies)
Discussion started by: jhilmil
4 Replies
Time::localtime(3pm)					 Perl Programmers Reference Guide				      Time::localtime(3pm)

NAME
Time::localtime - by-name interface to Perl's built-in localtime() function SYNOPSIS
use Time::localtime; printf "Year is %d ", localtime->year() + 1900; $now = ctime(); use Time::localtime; use File::stat; $date_string = ctime(stat($file)->mtime); DESCRIPTION
This module's default exports override the core localtime() function, replacing it with a version that returns "Time::tm" objects. This object has methods that return the similarly named structure field name from the C's tm structure from time.h; namely sec, min, hour, mday, mon, year, wday, yday, and isdst. You may also import all the structure fields directly into your namespace as regular variables using the :FIELDS import tag. (Note that this still overrides your core functions.) Access these fields as variables named with a preceding "tm_" in front their method names. Thus, "$tm_obj->mday()" corresponds to $tm_mday if you import the fields. The ctime() function provides a way of getting at the scalar sense of the original CORE::localtime() function. To access this functionality without the core overrides, pass the "use" an empty import list, and then access function functions with their full qualified names. On the other hand, the built-ins are still available via the "CORE::" pseudo-package. NOTE
While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this. AUTHOR
Tom Christiansen perl v5.16.3 2013-02-26 Time::localtime(3pm)
All times are GMT -4. The time now is 07:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy