this post was submitted on 25 Aug 2025
17 points (100.0% liked)

Shell Scripting

1524 readers
20 users here now

From Ash, Bash and Csh to Xonsh, Ysh and Zsh; all shell languages are welcome here!

Rules:
  1. Follow Lemmy rules!
  2. Posts must relate to shell scripting. (See bottom of sidebar for more information.)
  3. Only make helpful replies to questions. This is not the place for low effort joke answers.
  4. No discussion about piracy or hacking.
  5. If you find a solution to your problem by other means, please take your time to write down the steps you used to solve your problem in the original post. You can potentially help others having the same problem!
  6. These rules will change as the community grows.

Keep posts about shell scripting! Here are some guidelines to help:


In general, if your submission text is primarily shell code, then it is welcome here!

founded 2 years ago
MODERATORS
 

cross-posted from: https://lemmy.ml/post/35169329

Using a shell script, can I watch a folder and block program execution until a file in a certain folder changes?

top 2 comments
sorted by: hot top controversial new old
[โ€“] sin_free_for_00_days@sopuli.xyz 8 points 18 hours ago* (last edited 18 hours ago) (1 children)

inotifywait /path/to/file

Example:

inotifywait test.file; echo "test.file just changed"

Then in another terminal do something like touch test.file

[โ€“] helloworld@lemmy.ml 8 points 17 hours ago* (last edited 17 hours ago)

Thanks for your hint! After some experimentation and man page reading, this was what I was interested in:

inotifywait --event modify,create ./targetfolder/; echo "new change, that I am interested in, occurred in targetfolder";

I was interested in both file modification and file creation events.