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

Reply via email to