By mswatcher
via blogs.msdn.com
Published: Dec 03 2008 / 06:40
I wanted to sum the total lines of code in files in a given folder. I thought that writing my own program to do this would be faster than looking for it on the internet, so here's what I came up with
Comments
newton_dave replied ago:
Spoiler: here's the one line of code.
Here's mine:
Throw a tail in there if you only want the sum, a -l if you only want the lines.
Apparently somebody already thought of that.
b.m replied ago:
Your code should be:
find . -name "*" -type f | xargs wc
Plus you need to take into account the "recursive" /s parameter (in your case to ignore it). I've just posted my approach in groovy on dzone regarding this issue.
newton_dave replied ago:
Ah, good point--I missed that when scanning the one line. Thank goodness for -maxdepth :D
Voters For This Link (6)
Voters Against This Link (5)