|
|
|
|
|
by thelastnode
5325 days ago
|
|
For find, you need to use single quotes so your shell doesn't automatically expand the .java glob into the names of all the files. Also, find uses one dash for parameters, and can take an exec parameter:
find . -name .java -exec wc -l {} \; The {} means "replace with filename" and the semicolon (escaped so your shell doesn't eat it). This will run wc -l <filename> for every file that matches. The -regex flag lets you do the same thing as -name with regular expressions. The problem with this is we run n different wc's, as opposed to just one with all the parameters. We can use xargs to fix this:
find . -name .java | xargs wc -l This even gives you a total! The really* simple solution (which is probably best) is to just use shell globbing:
wc -l *.java While find and xargs are definitely useful, the easy solution here works better |
|