Skip to main content
1 of 2
waltinator
  • 6.9k
  • 1
  • 25
  • 27

Your whole approach is suboptimal! Misuse of find, just checking if find says the file exists (or not, rather than if it's changed), ...

The file's existence (or not) can be checked with bash's [[ -f "/path/to/file" ]] exoression.

The file's "change date", or "modification time" is available from man stat.

An example of "monitor a file, do something when it changes", can be extracted from my net-o-matic script, available from https://github.com/waltinator/net-o-matic. IMHO it's a good lump of bash programming.

waltinator
  • 6.9k
  • 1
  • 25
  • 27