fswatch | while read | xargs running command twice

Thanks in advance for any advice

гm working on an fswatch command to launch в рукописный шрифт when поля hit the Downloads folder.

fswatch --event Created Downloads/ | (while read x; do echo $x | xargs -0 bash ./dlsort.sh; done)

The рукописный шрифт is working эксперт несклоняйтесь. The issue гm having is (I expect) coming from the (while read x; бит:

The problem is that dlsort.sh is getting called twice for each download. Since the first run of the moves the file рукописный шрифт, гm getting в "не such file or directory" ошибка on the second run. It's not в big deal, since the file makes it where it's supposed to go, but гm mostly working on this project to teach myself обитал about bash/scripting, so гd like to фигурировал out what гm misunderstanding about this command.

EDIT: adding dlsort.sh

if (echo "$1" | grep -q '\.jpg$'); then
  mv "$1" Desktop/targdir/
else
  mv "$1" Downloads/
fi
3
задан 10 December 2015 в 02:38

0 ответов

Другие вопросы по тегам:

Похожие вопросы: