5 ms·
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
by Something1234 8y ago
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.
- adamdrake 8y agoYes, it does. Spoiler alert: I remove it at the end. ;)
- Something1234 8y agoStill I like the article. I just learned about useless use of cat the hard way. The biggest way I learned was cat /dev/zero | pv > /dev/null pv > /dev/null < /dev/zero The second one is much faster.
- tzahola 8y agoArgument list too long!
- Something1234 8y agoIncrease your stack size then. ulimit -s 65536 https://unix.stackexchange.com/a/45584/115135 https://unix.stackexchange.com/a/45584/115135
- pwg 8y agoThen do: 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.