Top Forums UNIX for Advanced & Expert Users how to find files older than 4hours in HP-UX Post 302147551 by jim mcnamara on Tuesday 27th of November 2007 12:56:58 PM
One way using perl:
    perl  -e '
         $mtime = (stat $ARGV[0])[9];
          print $mtime;
         '  $1
now=$(date +%s)
now=$(( $now - 14400 ))
find /path/to/file -type f | \
while read filename 
     ftime=$(filetime $filename)
     if [[ $ftime -ge $now ]] ; then
     rm -f $file

Test Your Knowledge in Computers #267
Difficulty: Easy
In 1935, at the age of 22, Alan Turning was elected a fellow of King's on the strength of a dissertation in which he proved the central limit theorem.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find files older than 20 days & not use find

I need to find files that have the ending of .out and that are older than 20 days. However, I cannot use find as I do not want to search in the directories that are underneath the directory that I am searching in. How can this be done?? Find returns files that I do not want. (2 Replies)
Discussion started by: halo98
2 Replies

2. Shell Programming and Scripting

only find files older than x minutes old

I am looking for a way to show files that have been created within a certain period (say anything older than 10 minutes or so). Is there a command/series of commands I can do this with? As an example, I have the following in a directory: -rw-r--r-- 1 owner group 70175 May 16 09:10... (1 Reply)
Discussion started by: dsimpg1
1 Replies

3. AIX

how to find files older than 2 hours

I need help to find files in a directory that are older than 2 hours. Any help would be great. (3 Replies)
Discussion started by: pt14
3 Replies

4. Shell Programming and Scripting

How to find files older than 30 days

Dear Friends, I have two queries. 1) I want to see the list of folders which were created 29 days ago. 2) I want to see the folders in which last created file is older than 29 days. Can it be done? Thank you in advance Anushree (4 Replies)
Discussion started by: anushree.a
4 Replies

5. UNIX Desktop Questions & Answers

Find files older than 10 days

What command arguments I can use in unix to list files older than 10 days in my current directory, but I don't want to list the hidden files. find . -type f -mtime +15 -print will work but, it is listing all the hidden files., which I don't want. (4 Replies)
Discussion started by: Pouchie1
4 Replies

6. Shell Programming and Scripting

find files older than and containing then tar.

I'm tring to: find files recursively older than x days that contain dat or DAT then tar them I can find the files older than 90 days containing dat with this: find . -mtime +90 -type f -name "*dat*" -exec tar -cvvfp /some/path/some.tar {} \; but how do I do it case insensitive? ... (3 Replies)
Discussion started by: Ikon
3 Replies

7. Shell Programming and Scripting

Find files older than 8 hours

I need a script to find files older than 8 hours... I know i can use mmin but the same is not working...the same only support mtime... This is the script i created..but the same is only giving 1 hour I have given dt_H as 1 only...but if i give can go in -(negative) to get the... (5 Replies)
Discussion started by: cotton
5 Replies

8. UNIX for Dummies Questions & Answers

Find files older than 2010?

Hi, I need to delete all files, in a folder, older than 2010 that is 2009, 2008 ,.. files... Can anyone suggest the command for that,... Thanks ---------- Post updated at 03:29 PM ---------- Previous update was at 02:53 PM ---------- humm,.. ok right now I am using the following:... (4 Replies)
Discussion started by: Mack1982
4 Replies

9. UNIX for Advanced & Expert Users

find files older than 30 days old

Hello, I have a script which finds files in a directory that are older than 30 days and remove them. The problem is that these files are too many and when i run this command: find * -mtime +30 | xargs rm I run this command inside the directory and it returns the error: /usr/bin/find:... (8 Replies)
Discussion started by: omonoiatis9
8 Replies

10. Shell Programming and Scripting

Find older files than specified date

Hi, I need to find out list of files which are older than specific date. I am using 'find, and newer' commands but its not giving the correct result. Can you please help to findout the list of files. thanks (2 Replies)
Discussion started by: Satyak
2 Replies
File::Listing(3)					User Contributed Perl Documentation					  File::Listing(3)

File::Listing - parse directory listing SYNOPSIS
use File::Listing qw(parse_dir); $ENV{LANG} = "C"; # dates in non-English locales not supported for (parse_dir(`ls -l`)) { ($name, $type, $size, $mtime, $mode) = @$_; next if $type ne 'f'; # plain file #... } # directory listing can also be read from a file open(LISTING, "zcat ls-lR.gz|"); $dir = parse_dir(*LISTING, '+0000'); DESCRIPTION
This module exports a single function called parse_dir(), which can be used to parse directory listings. The first parameter to parse_dir() is the directory listing to parse. It can be a scalar, a reference to an array of directory lines or a glob representing a filehandle to read the directory listing from. The second parameter is the time zone to use when parsing time stamps in the listing. If this value is undefined, then the local time zone is assumed. The third parameter is the type of listing to assume. Currently supported formats are 'unix', 'apache' and 'dosftp'. The default value is 'unix'. Ideally, the listing type should be determined automatically. The fourth parameter specifies how unparseable lines should be treated. Values can be 'ignore', 'warn' or a code reference. Warn means that the perl warn() function will be called. If a code reference is passed, then this routine will be called and the return value from it will be incorporated in the listing. The default is 'ignore'. Only the first parameter is mandatory. The return value from parse_dir() is a list of directory entries. In a scalar context the return value is a reference to the list. The directory entries are represented by an array consisting of [ $filename, $filetype, $filesize, $filetime, $filemode ]. The $filetype value is one of the letters 'f', 'd', 'l' or '?'. The $filetime value is the seconds since Jan 1, 1970. The $filemode is a bitmask like the mode returned by stat(). COPYRIGHT
Copyright 1996-2010, Gisle Aas Based on (from Lee McLoughlin's ftp mirror package) and Net::FTP's parse_dir (Graham Barr). This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.3 2012-02-15 File::Listing(3)

Featured Tech Videos

All times are GMT -4. The time now is 01:53 AM.
Unix & Linux Forums Content Copyright 1993-2019. All Rights Reserved.
Privacy Policy