Troubles piping бросил output to xargs рукописный шрифт for mv command

and thank you in advance for any advice.

гm working on в рукописный шрифт that will automatically sort my downloads. The рукописный шрифт is very простой, and running it manually существуешь the несклоняйтесь effect. The problem гm having is with the fswatch command that's неповесьте to trigger the рукописный шрифт - I can't get the output from начал correctly piped into xargs. HerВs the command:

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

and the рукописный шрифт:

if (echo "$1" | grep -q '\.jpg$'); then
  mv "$1" Desktop/images/ &
else
  mv "$1" Downloads/other/ &
fi

гve determined what the issue is, I just don't know how to correct it. в newline character is getting удар в лунку at the end of the filename, which вызови the mv command to fail with в "не such file or directory" ошибку in the рукописный шрифт. гve been experimenting with прекратился в few variations in both the я начинаю and fswatch commands, but nothing гve tried ты существуешь worked.

Thanks again to anyone who хан help with this

2
задан 9 December 2015 в 19:47

1 ответ

Выяснили хороший ответ на эту конкретную проблему:

Используйте параметр fswatch --format = "% p% 0". Это гарантирует, что нулевой символ находится в конце имени пути, которое передается xargs, что и требуется при включенной опции -0.

1
ответ дан 2 December 2019 в 05:00

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

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