I am trying to run a script which will watch different folder and files and if they change, execute a command. One of the folder paths accepts a dynamic variable which will change based on what is entered when running the script in the CLI, and the other one won't change.
Depending on the file path however, a different action needs to be taken.
#!/usr/bin/env bash
THEME=$1
while true;
do
echo "inside find"
find code/themes/$THEME/src -name '*.html' -o -name '*.ts' -o -name '*.scss' | entr -d rsync -avh code/themes/$THEME/* ./
find code/base/src -name '*.html' -o -name '*.ts' -o -name '*.scss' | entr -d rsync -avh code/base/* ./
done
What is happening when I run the script is that it only executes and places the watch on the first find (in the code pasted above's example, the dynamic path only).
Currently my problem is:
- Only the FIRST find gets called and only a watch placed on the code/themes/$THEME/src paths
- The second find never gets executed
How do I get both to run at once? Or, how can I write it all in one line?
Also, I have never written scripts or used bash before, so if you have any advice on refactoring or are able to help with my problem, please be gentle with technical explanations.
My main goal is:
- I want to set up a watch for any changes in path code/themes/$THEME/src
- i want to set up a watch for any changes in path code/base/src
- I want both watchers to be running at the same time