Created
August 11, 2011 11:48
-
-
Save hoodja/1139459 to your computer and use it in GitHub Desktop.
Quickly find project directories which have the fewest test files (really just fewest files)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in $(find . -name '*TestMain.cpp' -exec dirname {} \; | sort | uniq); do | |
echo "$(find $i -type f -depth 1 -maxdepth 1 | wc -l) $i"; | |
done | sort -n | head |
That just counts unique directory path names? I was wanting to count the number of files in any directory that contains a *TestMain.cpp file
…On Aug 11, 2011, at 11:27 PM, magnusstahre wrote:
How about this?
find . -name "_TestMain.cpp" | sed 's,/[^/]_$,,' | sort | uniq -c | sort -n
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/1139459
Good point. One thing to remember is that you are counting subdirectories as well as files now; if you just want to count files in a directory you can do something like
find $i -type f -depth 1 -maxdepth 1 | wc -l
I like that better - thanks Magnus!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How about this?