Sponsored Content
Top Forums UNIX for Dummies Questions & Answers HP UNIX: How to find files which are older than one hour. Post 302834473 by rbatte1 on Friday 19th of July 2013 04:37:25 AM
Old 07-19-2013
So, to work out the timestamp to generate the reference file you can use the date command on it's own if your system supports the options like this:-
Code:
touch -mt `date +%Y%m%d%H%M%S --date='1 hour ago'` /tmp/ref_file
find trg_dir -type f ! -newer /tmp/ref_file -name "*.aud"

If your OS does not support those date arguments, then you can play with the TZ variable to acheive the same result, thus:-
Code:
#!/bin/ksh
Orig_TZ="$TZ"
Offset=`echo $TZ|cut -f1 -d "," | tr -d "A-Z"`      # Get the numeric bit
P1_TZ="${TZ%%${Offset}*}"                           # Get the first part of the TZ
P2_TZ="${TZ#*${Offset}}"                            # Get the rest of the TZ after the offset

((Offset=$Offset+1))                                # Increase the value by one hour
TZ="${P1_TZ}${Offset}${P2_TZ}"                      # Set new timezone

ref_date=`date +%Y%m%d%H%M%S`                       # Get the value based on our adjusted TZ
TZ="$Orig_TZ"                                       # Reset back to original

touch -mt ${ref_date} ref_file

find trg_dir -type f ! -newer /tmp/ref_file -name "*.aud"


Does this suit your needs? Rather than use the TZ variable, you could of course get the values from the date command and build it up yourself, just taking one away from the hours, but then you'd have to handle going back past midnight, so change of day/month/year and it would get messier.


I hope that this helps, but if not, please explain what's wrong and what you need.


Robin
 

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. UNIX for Dummies Questions & Answers

display the files in a folder which are older than 1 hour

Hi, I have some files in a folder with different time stamps and I want to display the files which are older than 1 hour. i tried with find. need urgent help. (3 Replies)
Discussion started by: vgs
3 Replies

3. Shell Programming and Scripting

display the files in a folder which are older than 1 hour

Hi, I have some files in a folder with different time stamps and I want to display the files which are older than 1 hour. i tried with find. need urgent help. (7 Replies)
Discussion started by: vgs
7 Replies

4. Shell Programming and Scripting

unix command/s to find files older than 2 hours in a directory

I need to write a script to find files older than 2 hours in set of direcotries and list them ina mail. I know find command ti list files greater/lesser than days but i need to do it for hours. Any input. (6 Replies)
Discussion started by: Presanna
6 Replies

5. Shell Programming and Scripting

Find files modified in last hour sunOS 5.10

trying to find a way to locate files modified in the last hour in a shell script, unfortunately the command 'find . -mmin -60' is not supported on SunOS 5.10 (works on OpenSolaris 5.11 :mad:) Does anyone know a method of doing this in shell script on 5.10? cheers (19 Replies)
Discussion started by: rich@ardz
19 Replies

6. 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

7. Shell Programming and Scripting

Find and delete files and folders which are n days older from one unix server to another unix server

Hi All, Let me know how can i find and delete files from one unix server to another unix server which are 'N' days older. Please note that I need to delete files on remote unix server.So, probably i will need to use sftp, but question is how can i identify files and folders which are 'N'... (2 Replies)
Discussion started by: sachinkl
2 Replies

8. 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

9. 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

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
WMCALCLOCK(1)						      General Commands Manual						     WMCALCLOCK(1)

NAME
WMCALCLOCK - Dockable Calendar Clock SYNOPSIS
wmCalClock [-h] [-display <Display>] [-b <Volume>] [-e <Command>] [-24] [-s] [-S] [-L <Longitude>] [-l] [-tc <color>] [-bc <color>] [-tek- ton] [-comicsans] [-arial] [-luggerbug] [-jazz] DESCRIPTION
wmCalClock is a simple Calendar Clock with anti-aliased text and drop-shadows. OPTIONS
-h Display list of command-line options. -display [display] Use an alternate X Display. -b <Volume> Beep on the hour with specified volume (between -100 and 100). -e <Command> Command to execute via double click of mouse button 1. (Use quotes if your command has white space in it). -24 Show time in 24-hour format instead of default 12-hour AM/PM format. -30 Show local time in 30-hour format. Times between midnight and 6 AM are displayed as belonging to the previous day, so the hour ranges from 6 to 29. -g Show Greenwich Mean Time (GMT). -s Show Greenwich Mean Sidereal Time (GMST) in 24-hour format. -S Dont show seconds. -L <Longitude> Show Local Sidereal Time (LST) in 24-hour format. Longitude is in degrees (- for West + for East). -l Force use of lower color pixmap to conserve colors. On displays with <= 8 bits, the low color Pixmap will always be used. -tc <color> Change color of time-field digits. -bc <color> Change color of time-field background. -tekton Use the Tekton font for time field. -arial Use the Arial (i.e. Helvetica) font for time field. -jazz Use the JazzPoster font for time field. -luggerbug Use the LuggerBug font for time field. -comicsans Use the ComicSans font for time field. BUGS
Who knows? (Let me know if you find any). AUTHOR
Michael G. Henderson <mghenderson@lanl.gov> 16 December 1998 WMCALCLOCK(1)
All times are GMT -4. The time now is 01:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy