Install entr File Change Watcher on Ubuntu 26.04

Install entr File Change Watcher on Ubuntu 26.04

The entr is a lightweight command-line utility designed to monitor files for changes and automatically execute commands when modifications occur. It can be useful for development workflows where tests, scripts, or other tasks need to run whenever source files are updated. This tutorial shows how to install entr file change watcher on Ubuntu 26.04.

Install entr

Run the following command to update package lists:

sudo apt update

Install the entr:

sudo apt install -y entr

Testing entr

Create a JavaScript file to use for testing:

echo "console.log('Hello world');" > test.js

Start entr tool and monitor JavaScript files in the current directory:

find . -name '*.js' | entr -r echo 'File changed'

The find command supplies the list of JavaScript files to entr. When a change to test.js is detected, entr runs the echo command and displays "File changed" in the terminal. Press CTRL+C to stop entr.

Uninstall entr

When entr is no longer required, remove the package by using the following command:

sudo apt purge --autoremove -y entr

Leave a Comment

Cancel reply

Your email address will not be published.