![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to find files older than 2 hours | pt14 | AIX | 3 | 03-05-2008 12:31 PM |
| find files older than a given file | Shivdatta | Shell Programming and Scripting | 5 | 07-24-2006 07:25 AM |
| only find files older than x minutes old | dsimpg1 | Shell Programming and Scripting | 1 | 05-18-2006 11:48 PM |
| Find files older than 20 days & not use find | halo98 | Shell Programming and Scripting | 2 | 05-18-2006 02:19 PM |
| Find files older than 5 days and remove tem after listing | ypatel6871 | UNIX for Dummies Questions & Answers | 1 | 09-05-2005 11:00 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
One way using perl:
Code:
#!/bin/ksh
filetime()
{
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
do
ftime=$(filetime $filename)
if [[ $ftime -ge $now ]] ; then
continue
fi
rm -f $file
done
|
|
||||
|
You can do ! -newer
Code:
touch -t [4hours ago] touchfile
find /path/to/files ! -newer touchfile -exec rm -f {} \;
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|