Linux command
entr 命令
文件
涉及管道、覆盖或删除,执行前请先确认路径和参数。
常用示例
Run command when
ls [*.py] | entr [python test.py]
Clear screen before
ls [*.md] | entr -c [make html]
Restart command
ls [main.go] | entr -r [go run main.go]
Run once and exit
ls [config.yml] | entr -p [./deploy.sh]
Use tracked file
ls [*.js] | entr -s '[eslint /_]'
说明
entr runs commands when files change. It watches files listed on stdin and executes the specified command whenever any change is detected. The tool is ideal for development workflows: rerunning tests, rebuilding projects, or restarting servers on source changes. The -r flag handles processes that need restart rather than re-execution. entr uses efficient kernel file notification mechanisms (kqueue, inotify) rather than polling.
参数
- -c
- Clear screen before running.
- -r
- Restart persistent process.
- -p
- Postpone first execution.
- -s
- Execute with shell.
- -d
- Track directories for new files.
- -z
- Exit on process completion.
FAQ
What is the entr command used for?
entr runs commands when files change. It watches files listed on stdin and executes the specified command whenever any change is detected. The tool is ideal for development workflows: rerunning tests, rebuilding projects, or restarting servers on source changes. The -r flag handles processes that need restart rather than re-execution. entr uses efficient kernel file notification mechanisms (kqueue, inotify) rather than polling.
How do I run a basic entr example?
Run `ls [*.py] | entr [python test.py]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -c do in entr?
Clear screen before running.