koldfront

watchfile #shell

🕘︎ - 2025-06-09

Recently I was editing a Markdown file and I was converting it to HTML with pandoc for every edit.

Re-running the command quickly became tedious - I could use some kind of framework for editing Markdown or something elaborate, but what I really wanted was just "run a command when a file changes".

So, watchfile was born - it basically just wraps inotifywait from the inotify-tools package:

#!/bin/sh

# watchfile FILE COMMAND - run a command whenever a file changes.

FILE=$1
shift

while inotifywait --quiet --quiet "$FILE"; do
    echo -n "Running '$*' ... "
    "$@"
    echo "done."
done

Add comment

How to comment, in excruciating detail…

To avoid spam many websites make you fill out a CAPTCHA, or log in via an account at a corporation such as Twitter, Facebook, Google or even Microsoft GitHub.

I have chosen to use a more old school method of spam prevention.

To post a comment here, you need to:

  • Configure a newsreader¹ to connect to the server koldfront.dk on port 1119 using nntps (nntp over TLS).
  • Open the newsgroup called lantern.koldfront and post a follow up to the article.
¹ Such as Thunderbird, Pan, slrn, tin or Gnus (part of Emacs).

Or, you can fill in this form:

+=