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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting display the files in a folder which are older than 1 hour
# 1  
Old 05-25-2007
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.
# 2  
Old 05-25-2007
Search Forum before posting ...
See move log files over 12 hours old...
and date/time


Jean-Pierre.
# 3  
Old 05-25-2007
I have written the below ksh script(in sun solaris) using one old posting but i am getting an error message saying that " ./fileage: not found".

Looks like the fileage is not recognized.
please can any one help.

#!/bin/ksh
AGE=$1
cd c:/temp
for file in $(ls)
do
echo "in the for loop"
if [[ $(( $(./ $file)/60)) -ge $AGE ]]
then
echo $file >>outputfiles.txt
fi
done >outputfiles.txt

final=`wc -l outputfiles.txt|awk '{print $1}'`
if [ $final -ge 1 ]
then
echo $final|mailx -s "Unprocessed Files in blabla" abc.xyz@yahoo.com
else
echo "Everything's OK"
fi
# 4  
Old 05-25-2007
I don't understand what you want to do in the following statement :
Code:
if [[ $(( $(./ $file)/60)) -ge $AGE ]]

If possible, give us examples of input files and results that you expect.

Jean-Pierre.
# 5  
Old 05-25-2007
Quote:
Originally Posted by vgs
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.

Folder? Do you mean directory?

If you have GNU (or FreeBSD) find:

Code:
find . -maxdepth 1 -type 5 -mmin +60

# 6  
Old 05-29-2007
i am using sun Solaris.

i am trying to write a script which will display files from a particular folder(Directory)(should not include subdirectories) which are 2 hrs(this should be used like a variable so that i can change the time) older.

i tried using find command. but find looks in subdirectories also. I don't want to check in subdirectories.

files looks like:
12345600000.PDF
32455664647.XLS

appriciate your help.
# 7  
Old 05-29-2007
use prune option with find
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Hour display format

Hello Sir/Madam, I'm using Putty utility to run a shell script. I found HOUR display in two positions in UNIX. Is it possible to display in four positions? File name example: my file name is: HourlyData_20160708_1400.txt I'm in the process of comparing current date and time with the file... (15 Replies)
Discussion started by: V1l1h1
15 Replies

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

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

4. Shell Programming and Scripting

Script to delete files in a folder older than 2 days

hi i need a script to delete the files older than 2 days... if my input is say in a folder versions A_14122012.txt A_15122012.txt A_16122012.txt A_17122012.txt i want my output to be A_16122012.txt A_17122012.txt thanks in advance hemanth saikumar. (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

5. UNIX for Dummies Questions & Answers

move files older than 2 days to another folder

Hi I am facing problem in using this command, mv `find /export/june/PURGEDATA*.txt -mtime +2 -exec ls {} \;` june/archive/ mv: Insufficient arguments (1) Usage: mv f1 f2 mv f1 ... fn d1 mv d1 d2 Thank you in advance (2 Replies)
Discussion started by: vishwakar
2 Replies

6. Shell Programming and Scripting

Script which erases files in Folder older than....

Hi! Need a script which erases files in folder /home/appl/backup which are older than 3 weeks... Any idea how to do that? I'm still investigating, but a little speed-up would be nice! ;-) Thanks! Michael (2 Replies)
Discussion started by: Michi21609
2 Replies

7. Shell Programming and Scripting

Deleting the contents of a folder older than X hours

Every day a new .zip file is uploaded to a folder and at mid-night the zip file is to be extracted into a /data/ folder, inside a date-named folder. # This should extract the contents of a zip file into the /data/ folder into a date based folder /usr/bin/unzip -a -o... (15 Replies)
Discussion started by: worchyld
15 Replies

8. Shell Programming and Scripting

BASH condition for "File older than 1 hour"

I have a monitor script that executes every 5 minutes. I am adding functionality that will detect if a previous execution is hung. I have managed to do that by using a flag that is created when the monitor starts and is then removed when the monitor finishes. The hang check simply looks to see if... (2 Replies)
Discussion started by: Squeakygoose
2 Replies

9. Shell Programming and Scripting

Find files older then today & display with timestamp info

Small query- I want to do some operation on all the files older then today. Before I do that operation, i want to verify if the command works properly or not. Surprisingly, the command below returns me file, which are created today - find /mrk_archive/PG/ftp/incomming/gbs/2008 -type f... (2 Replies)
Discussion started by: kedar.mehta
2 Replies

10. 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
Login or Register to Ask a Question