Closed yi closed 10 years ago
Hi @yi, I strongly suggest you become familiar with regular expressions: there's a lot of literature on the Internet.
-e
is meant to exclude files, so that I advise against following this path if all you want is filtering event file names. To filter events whose file extension is .ext
you could use the following command:
fswatch -0 [options] ... [paths] ... | while read -d "" i
do
if echo $i | grep -q "^.*ext$" > /dev/null ; then
// do something
fi
done
If you want to keep things clean, you could use xargs
and put all the logic you need to run (including, of course, the filtering logic) into a script.sh
:
$ fswatch -0 [args] | xargs -0 -n 1 script.sh
Hope this helps, Enrico M. Crisostomo
Crystal clear and very helpful, thank you Mr. Enrico M. Crisostomo.
I was learning linux regular expressions, and got stuck on -e "\.moon$"
. I didn't know how to write logic NOT in the expression. My answer make me realise that I can use grep for further filtering.
Sorry, I'm a beginner of shell script. I will keep learning. And a big thank you for your kind help.
Thank you @yi. You're welcome, please feel free to post any issues, questions or suggestion you might have.
Hi I have tried -e and -E. But all failed, because I'm not familair with mac bash regexp.
Could you give me some hint. I wan to write a fsw command to do:
thanks a lot!