Hiya,

I hope you had a merry Christmas ;)

I am trying to determine the time of last modification of a file,
on FreeBSD.

The following code achieves the same on Linux:


# AGE = (current time) - (time of last modification of "$FILE")
# please check your systems 'stat' command!
AGE=$(($(date +%s) - $(stat -c '%Y' "$FILE")))

test $AGE -lt $DELAY && {
        echo -n yes
        exit 0
}


Here is the whole bash script, just so that everything is clear:

<cut>

#!/usr/local/bin/bash
test -t 0 && trap "echo" EXIT

NAME="$1"; shift
DELAY="${1:-600}"; shift
BASE="${1:-/var/run/greydata}"; shift

NAME=${NAME//.//}
DIR=$BASE/${NAME%/*}
FILE=$DIR/${NAME##*/}


test -d "$DIR" || mkdir -p "$DIR"

test -f "$FILE" || {
        > "$FILE"
        echo -n yes
        exit 0 
}

# AGE = (current time) - (time of last modification of "$FILE")
# please check your systems 'stat' command!
AGE=$(($(date +%s) - $(stat -c '%Y' "$FILE")))

test $AGE -lt $DELAY && {
        echo -n yes
        exit 0
}

read <"$FILE"
echo -n no
exit 0

</cut>


The `stat -c` is illegal for FreeBSD. However I don't seem to understand 
clearly what the man page for stat is telling me, to enable me make this
work.






-Wash

http://www.netmeister.org/news/learn2quote.html

DISCLAIMER: See http://www.wananchi.com/bms/terms.php

--
+======================================================================+
    |\      _,,,---,,_     | Odhiambo Washington    <[EMAIL PROTECTED]>
Zzz /,`.-'`'    -.  ;-;;,_ | Wananchi Online Ltd.   www.wananchi.com
   |,4-  ) )-,_. ,\ (  `'-'| Tel: +254 20 313985-9  +254 20 313922
  '---''(_/--'  `-'\_)     | GSM: +254 722 743223   +254 733 744121
+======================================================================+

What is mind?  No matter.
What is matter?  Never mind.
                -- Thomas Hewitt Key, 1799-1875
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to