Piped shell \input

Andreas Scherer andreas_tex at freenet.de
Tue Jun 21 19:32:28 CEST 2022

Hello again,

> ... the desired compact version
>     \newcount\countD \countD=0
>     \ifpdftex \ifnum\pdfshellescape=1
>       \countD=\input{|"grep \\\\:\\\\X \jobname.tex | wc -l"} \fi\fi

can be accomplished as such:

   \ifpdftex \ifnum\pdfshellescape=1 {\let\\=\BS
     \global\countD=\input{|grep -c -e '\\:\\X' \jobname.tex}} \fi\fi

Thanks to the '-c' option of 'grep' (tested with GNU grep on Linux and 
with BSD grep on macOS) we get rid of 'wc -l'. Thanks to '\BS' we get 
the backslash in the regular expression. In all, 'countmodules' can be 

Case closed!

More information about the texhax mailing list.