Bash script — determine if file modified?
Posted
by
Alan H.
on Stack Overflow
See other posts from Stack Overflow
or by Alan H.
Published on 2011-01-14T21:26:41Z
Indexed on
2011/01/15
2:53 UTC
Read the original article
Hit count: 388
I have a Bash script that repeatedly copies files every 5 seconds. But this is a touch overkill as usually there is no change.
I know about the Linux command watch
but as this script will be used on OS X computers (which don’t have watch
, and I don’t want to make everyone install macports) I need to be able to check if a file is modified or not with straight Bash code.
Should I be checking the file modified time? How can I do that?
Edit: I was hoping to expand my script to do more than just copy the file, if it detected a change. So is there a pure-bash way to do this?
© Stack Overflow or respective owner