I’m using bash to count my lines of source in a project. Here’s the code:
#!/bin/bash
find . -name '*.java' | xargs wc -l
find . -name '*.xml' | xargs wc -l
I want to exclude files from the ./gen folder. I think it’s something to do with ‘prune’, but I can’t figure out how to do it.
EDIT
Thankyou to ruakh, but his code wasn’t my final solution, I had to make it count the lines again. Here’s the finished thing if anybody wants it:
#!/bin/bash
find . -path ./gen -prune -o -name '*.java' | xargs wc -l
find . -name '*.xml' | xargs wc -l
I couldn’t make ruakh’s solution work and ended up with the following instead:
Also found an interesting
egrepoption based on GNU find:In order to count lines in the matched files you can stick
xargs cat | wc -lon the end: