Use filedate, substract current filedate with the filedate of your file
in /dir1/sub1/ if result -gt 600 then move files

Thanks,
Niel

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jhuniepi
Sent: Wednesday, April 05, 2006 9:14 AM
To: Philippine Linux Users' Group (PLUG) Technical Discussion List
Subject: [plug] subtracting dates in bash script

hello to all,

in a directory there are list of files. /dir1/sub1/* i want to move
those files in /dir1/sub1/* to /dir1/sub2/*, only if the file in
/dir1/sub1/ is ten minutes older or more than the current datetime.

i created a script but my problem is how do i know if file timestamp is
older than the current datetime. it's like this: current datetime - file
timestamp. how to do that in bash script?

here's my incomplete script :

#!/bin/env bash

SRCDIR=/dir1/sub1
DESDIR=/dir1/sub2
now=(current date)

cd $SRCDIR
for f in *
do
ftimestamp=(file timestamp)
if [ -f $f ]
then
  if [ ($now - $ftimestamp) -ge (ten minutes) ]
  then
    mv $f $DESDIR
    echo $f moved to $DESDIR
  fi
fi
done

#script ends

TIA
--
cj pangilinan
linux user, java programmer
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
[email protected] (#PLUG @ irc.free.net.ph) Read the Guidelines:
http://linux.org.ph/lists Searchable Archives:
http://archives.free.net.ph
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
[email protected] (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph

Reply via email to