Is there a way to execute a command whenever a file changes in Linux?

1142910 pts.
Tags:
Linux
Unix
I'm looking for a way to execute a command whenever a file changes in Linux. I need something very quick and simple. Basically something like whenever I'm running a file on a terminal and close it whenever I'm finished with it. This is what I'm using now:
while read; do ./myfile.py ; done
But for this, I have to go into the terminal and click enter (whenever I save it). I need something like this:
while sleep_until_file_has_changed myfile.py ; do ./myfile.py ; done
Can I do something like this? Thanks!
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: