Sponsored Content
Top Forums Shell Programming and Scripting Mtime or the equivalent for HP-UX Post 303031230 by Chubler_XL on Sunday 24th of February 2019 06:00:23 PM
Old 02-24-2019
You could use perl to test if file is older that 3 days like this:

Code:
$ FILE=.profile
$  perl -e 'use File::stat;  my $INODE=stat("'$FILE'"); exit((time() - $INODE->mtime) < 3600*24*3);' && echo "File $FILE is old"
File .profile is old

Or (not a big perl coder so this could probably be simplified). Print filenames on stdin, older than 3 days:

Code:
$ ls | perl -e '
  use File::stat;
  while (my $fl = <STDIN>) { 
    chomp $fl ;
    my $INODE=stat($fl); 
    if(time() - $INODE->mtime > 3600*24*3) { 
       print $fl . "\n";
    } 
  }'


Last edited by Chubler_XL; 02-24-2019 at 07:07 PM.. Reason: Clean up formatting
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

mtime vs ctime

:D i have a slight problem and would appreciate if someone could clarify the confusion.. i use find alot and so far i have done ok.. but it just struck me a couple of days ago that I am not quite sure what the difference between the modification time and the change time as in ctime and mtime and... (3 Replies)
Discussion started by: moxxx68
3 Replies

2. UNIX for Dummies Questions & Answers

find . -mtime

...what am i doing wrong?? I need to find all files older than 30 days and delete but I can't get it to pull details for ANY + times. The file below has a time stamp which is older than 1 day, however if I try and select it using any of the -time flags it just doesn't see it. (the same thing... (1 Reply)
Discussion started by: topcat8
1 Replies

3. UNIX for Dummies Questions & Answers

mtime help!!!!!

thank you for the help. (2 Replies)
Discussion started by: scooter17
2 Replies

4. Shell Programming and Scripting

mtime

hi, :) consider the following statement find . -type f -mtime -1 -print here what is the use of -1 option. any help? cheers RRK (7 Replies)
Discussion started by: ravi raj kumar
7 Replies

5. UNIX for Dummies Questions & Answers

-mtime +30

Hello, Can someone help me to understand the following: find /test/rman/ -mtime +30 -exec rm '{}' \; What does -mtime +30 mean? Thanks! (1 Reply)
Discussion started by: Blue68
1 Replies

6. Shell Programming and Scripting

mtime

Hi, I've some files of some past days and everyday some new files are also getting added to the same. Now how can i use mtime to get the files of the current date i.e if i want the files of 25th feb 2009 and if im finding the files on 25th 12:10 am then i should only get the files after... (4 Replies)
Discussion started by: ss_ss
4 Replies

7. UNIX for Dummies Questions & Answers

(find) mtime vs. (unix) mtime

Hi I've made some test with perl script to learn more about mtime... So, my question is : Why the mtime from findfind /usr/local/sbin -ctime -1 -mtime -1 \( -name "*.log" -o -name "*.gz" \) -print are not the same as mtime from unix/linux in ls -ltr or in stat() function in perl : stat -... (2 Replies)
Discussion started by: hiddenshadow
2 Replies

8. Shell Programming and Scripting

find -mtime +7

Dear all, find $ADMIN_DIR/$SID/arch/ -name '*.gz' -mtime +7 -exec rm {} \; is it retaining 7 days OR 8 days .gz files ? Thanks Prakash (10 Replies)
Discussion started by: prakashoracledb
10 Replies

9. Red Hat

-mtime command

Hello, what this command do. find /oracle/u01/app/oracle/admin/rdz/udump/ -name "*.trc" -mtime +1 Thanks, Umair (1 Reply)
Discussion started by: umair
1 Replies

10. Shell Programming and Scripting

Mtime issue

Dear all, i am trying to find all files created one day before, for example 26 October, and i am using this command: find . -type f -daystart -mtime 1 This command in fact lists all files created on 26 October, but the files between midnight 00:00 26 Oct and 01:00 26 Oct, does not shown... (4 Replies)
Discussion started by: arrals_vl
4 Replies
File::stat(3pm) 					 Perl Programmers Reference Guide					   File::stat(3pm)

NAME
File::stat - by-name interface to Perl's built-in stat() functions SYNOPSIS
use File::stat; $st = stat($file) or die "No $file: $!"; if ( ($st->mode & 0111) && $st->nlink > 1) ) { print "$file is executable with lotsa links "; } if ( -x $st ) { print "$file is executable "; } use Fcntl "S_IRUSR"; if ( $st->cando(S_IRUSR, 1) ) { print "My effective uid can read $file "; } use File::stat qw(:FIELDS); stat($file) or die "No $file: $!"; if ( ($st_mode & 0111) && ($st_nlink > 1) ) { print "$file is executable with lotsa links "; } DESCRIPTION
This module's default exports override the core stat() and lstat() functions, replacing them with versions that return "File::stat" objects. This object has methods that return the similarly named structure field name from the stat(2) function; namely, dev, ino, mode, nlink, uid, gid, rdev, size, atime, mtime, ctime, blksize, and blocks. As of version 1.02 (provided with perl 5.12) the object provides "-X" overloading, so you can call filetest operators ("-f", "-x", and so on) on it. It also provides a "->cando" method, called like $st->cando( ACCESS, EFFECTIVE ) where ACCESS is one of "S_IRUSR", "S_IWUSR" or "S_IXUSR" from the Fcntl module, and EFFECTIVE indicates whether to use effective (true) or real (false) ids. The method interprets the "mode", "uid" and "gid" fields, and returns whether or not the current process would be allowed the specified access. If you don't want to use the objects, you may import the "->cando" method into your namespace as a regular function called "stat_cando". This takes an arrayref containing the return values of "stat" or "lstat" as its first argument, and interprets it for you. 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 stat() and lstat() functions.) Access these fields as variables named with a preceding "st_" in front their method names. Thus, "$stat_obj->dev()" corresponds to $st_dev if you import the fields. 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. BUGS
As of Perl 5.8.0 after using this module you cannot use the implicit $_ or the special filehandle "_" with stat() or lstat(), trying to do so leads into strange errors. The workaround is for $_ to be explicit my $stat_obj = stat $_; and for "_" to explicitly populate the object using the unexported and undocumented populate() function with CORE::stat(): my $stat_obj = File::stat::populate(CORE::stat(_)); ERRORS
-%s is not implemented on a File::stat object The filetest operators "-t", "-T" and "-B" are not implemented, as they require more information than just a stat buffer. WARNINGS
These can all be disabled with no warnings "File::stat"; File::stat ignores use filetest 'access' You have tried to use one of the "-rwxRWX" filetests with "use filetest 'access'" in effect. "File::stat" will ignore the pragma, and just use the information in the "mode" member as usual. File::stat ignores VMS ACLs VMS systems have a permissions structure that cannot be completely represented in a stat buffer, and unlike on other systems the builtin filetest operators respect this. The "File::stat" overloads, however, do not, since the information required is not available. 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.2 2012-10-25 File::stat(3pm)
All times are GMT -4. The time now is 08:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy