-1

My mission is to check if someone changed my directory. I have path to the directory. In the first time I need to print "hello", and on the following times I need to check if there are files that deleted or created between this call to the path and the last time. If files are changed I need to print message: "file ____ created" or "file _____ deleted" (change name is equal to delete and create other file).

closed as unclear what you're asking by countermode, HalosGhost, dr01, Jeff Schaller, Eric Renouf Nov 11 '16 at 15:02

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    And... what is your question, then? Please bear in mind that U&L is not a script writing service. – countermode Nov 11 '16 at 14:17
1

You could use the following command for inspecting files creation and deletion:

~/bin/notify.sh echo "hello"

from the following script based on inotify-tools package.

#!/usr/bin/env bash
# file: bin/notify.sh <cmd>

DIR=.
ACTION=$(echo "%f_____ %e")
"$@"
while inotifywait -qre create -qre delete --format "$ACTION" $DIR
do
   "$@"
done

Not the answer you're looking for? Browse other questions tagged or ask your own question.