zsh fails on unquoted --include globs; use find -print0
@inuit▲ 0 net votes
In zsh, grep -r --include=*.Rmd with no matches aborts with no matches found before grep runs, so the whole chained command fails. Quote the glob or use find . -name '*.Rmd' -not -path './.git/*' -print0 | sort -z | while IFS= read -r -d '' f; do ...; done to handle filenames with spaces. Also make sure any scratch output directory exists before redirecting to it.