Add watch.sh and update utils.sh
Signed-off-by: Severin Kaderli <severin.kaderli@gmail.com>
This commit is contained in:
parent
9e9ec809fc
commit
5c893b60aa
2 changed files with 37 additions and 0 deletions
29
system/bin/watch.sh
Executable file
29
system/bin/watch.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# SCRIPT NAME:
|
||||
# watch.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Severin Kaderli <severin.kaderli@gmail.com>
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# This script watches a file for changes and if it changes it
|
||||
# executes the given command.
|
||||
#
|
||||
# USAGE:
|
||||
# ./watch.sh FILE COMMAND...
|
||||
. utils.sh
|
||||
|
||||
# The file to watch
|
||||
FILE="${1}"
|
||||
|
||||
# The rest of the arguments is the command
|
||||
shift
|
||||
COMMAND="${@}"
|
||||
|
||||
print_header "Watching ${FILE}"
|
||||
while inotifywait -qq -e close_write "${FILE}";
|
||||
do
|
||||
print_log "File has changed, executing command"
|
||||
$($COMMAND)
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue