News for hackers. Stuff that matters.
Re:What's the one Linux command you wish you knew years ago? by sjs on Sunday November 20, 2011 @02:43AM (#3257557)
You'll want to quote .java so the shell doesn't interpret it as a glob, and find doesn't use GNU style flags. You can also pass wc the filenames directly like this:

    wc -l $(find . -name '*.java')
Re:What's the one Linux command you wish you knew years ago? by jedbrown on Sunday November 20, 2011 @02:51AM (#3257568)
That has different semantics (it prints one line per file) and can have line length limitations. This has the same semantics as the parent's version, but without line length issues.

  find . -name \*.java -exec cat {} + | wc -l
Re:What's the one Linux command you wish you knew years ago? by X-Istence on Sunday November 20, 2011 @03:26AM (#3257619)
Note that the + may not be portable. I know it doesn't work on older Solaris versions (<10) and HP-UX (from a couple years ago when I last touched it).

Also, find may or may not split the files it finds into multiple invocations.

Re:What's the one Linux command you wish you knew years ago? by Karellen on Sunday November 20, 2011 @08:36AM (#3258060)
Too many invocations of "cat"

find . -name \*.java -print0 | xargs -0 cat | wc -l

Edit: Dammit. Others have already posted this exact version further below. :-(

Re:What's the one Linux command you wish you knew years ago? by tikhonj on Sunday November 20, 2011 @02:52AM (#3257571)
Yeah, the flags always get me. For some reason, I've never had issues with the *. It's good to know about passing files to wc directly.

I just use M-x find-dired and friends these days for most things, admittedly.