by Something1234 · 8y ago · 0 comments
cat *.pgn | grep "Result" | sort | uniq -c
This pipeline has a useless use of cat. Over time I've found cat to be kind of slow as compared to actually passing a filename to a command when I can. If you rewrite it to be: grep -h "Result" *.pgn | ...
It would be much faster. I found this when I was fiddling with my current log processor to analyze stats on my blog. cat /dev/zero | pv > /dev/null
pv > /dev/null < /dev/zero
The second one is much faster. Argument list too long!find -name \*.pgn -print0 | xargs -0 grep -h "Result"
Each grep invocation will consume a maximum number of arguments, and xargs will invoke the minimum number of greps to process everything, with no "args too long" errors.
ulimit -s 65536
https://unix.stackexchange.com/a/45584/115135