No edit summary |
(Formating, adding `find` method) |
||
Line 2: | Line 2: | ||
== Method 1 == |
== Method 1 == |
||
+ | <pre> |
||
− | |||
awk 'END {print NR}' *.java |
awk 'END {print NR}' *.java |
||
+ | </pre> |
||
− | |||
== Method 2 == |
== Method 2 == |
||
Line 13: | Line 13: | ||
This will output the line count for each file, but with a total at the end as well. |
This will output the line count for each file, but with a total at the end as well. |
||
− | Method 3 |
+ | == Method 3 == |
+ | <pre> |
||
− | |||
cat *.java | wc -l |
cat *.java | wc -l |
||
+ | </pre> |
||
+ | |||
+ | == Method 4 == |
||
+ | Using find to generate a list of files, useful when files are in sub directories. |
||
+ | |||
+ | <pre> |
||
+ | wc -l `find -name '*.java'` |
||
+ | </pre> |
||
[[Category:Howto]] |
[[Category:Howto]] |
||
[[Category:Bash shell]] |
[[Category:Bash shell]] |
Revision as of 10:01, 22 February 2012
Method 1
awk 'END {print NR}' *.java
Method 2
wc -l *.php
This will output the line count for each file, but with a total at the end as well.
Method 3
cat *.java | wc -l
Method 4
Using find to generate a list of files, useful when files are in sub directories.
wc -l `find -name '*.java'`