Scroll to navigation

ENTR(1) General Commands Manual ENTR(1)

NAME

entr
run arbitrary commands when files change

SYNOPSIS

entr [
-r
] [
-c
] utility [
argument ...
] [
/_
]

entr +fifo

DESCRIPTION

entr has two modes of operation; the first use reads a list of files provided on STDIN and executes the supplied utility if any of them change. entr waits for the child process to finish before responding to subsequent file system events. A TTY is opened before entering the watch loop in order to support the invocation of interactive utilities.
-r modifies the exec mode by launching the utility at startup and reloading it if one of the source files change. This features requires the application to exit if it receives SIGTERM. entr always waits for the utility to exit to ensure that resources such as sockets have been closed.
The second mode also reads a list of filenames provided on STDIN and is enabled by specifying '+' and the name of a fifo. In this mode entr enables more sophisticated scripting by writing filenames to a named pipe when they are modified.

SHORTCUTS

A limited number of features are provided simply to save keystrokes.
-c clears the screen before running the utility.
The first occurrence of /_ on the command line will be replaced with the absolute path of the first file under watch. This is most useful for running or processing a single file.

ENVIRONMENT

If PAGER is undefined, entr will assign /bin/cat to prevent interactive utilities from waiting for keyboard input if output does not fit on the screen.

EXIT STATUS

The entr utility does not normally return, but it will exit with a value of 0 if the signal SIGINT or SIGTERM was received. An exit status of 1 indicates that no regular files were provided as input.

EXAMPLES

Rebuild project when source files change
$ find src | entr make
Clear the screen and run tests
$ ls *.py | entr -c ./test.py
Launch and auto-reload a node.js server
$ ls *.js | entr -r node index.js
Run an SQL query
$ echo my.sql | entr psql -f /_
Convert individual Markdown files to HTML if they're modified
$ ls *.md | entr +notify &
$ while read F; do
> markdown2html $F
> done < notify

CAVEATS

Only regular files are monitored, directories and special files are ignored.
January 6, 2014 Debian