I ran the following command :
time for i in {1..100}; do find / -name "*.service" | wc -l; done
got a 100 lines of the result then :
real 0m35.466s user 0m15.688s sys 0m14.552s
I then ran the following command :
time for i in {1..100}; do find / -name "*.service" | awk 'END{print NR}'; done
got a 100 lines of the result then :
real 0m35.036s user 0m15.848s sys 0m14.056s
I precise I already ran find / -name "*.service"
just before so it was cached for both commands.
I expected wc -l
to be faster. Why is it not ?