码迷,mamicode.com
首页 > 其他好文 > 详细

统计文件行数

时间:2015-01-12 16:13:16      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

统计文件行数(单个文件):

wc -l file

例如:

homer@ubuntu:~/workspace/android/game$ wc -l LGameAndroid2DActivity.java 
906 LGameAndroid2DActivity.java

 

统计目录所有文件行数(全部目录):

find . -name *.java | xargs wc -l

例如:

homer@ubuntu:~/workspace/android$ find . -name *.java | xargs wc -l
    817 ./game/core/LHandler.java
    140 ./game/core/LFlicker.java
    ...
    515 ./game/utils/collection/ArrayMap.java
    162 ./game/utils/CollisionUtils.java
    178 ./game/utils/NumberUtils.java
  68753 total

 

统计目录并按行数排序(按行大小排序):

 find . -name *.java | xargs wc -l | sort -n

homer@ubuntu:~/workspace/android$ find . -name *.java | xargs wc -l | sort -n
     25 ./game/action/sprite/Collidable.java
     26 ./game/core/graphics/component/CollisionQuery.java
     27 ./game/core/graphics/filter/ImageFilter.java
     28 ./game/LMode.java
     ...
   1467 ./game/core/geom/Path2D.java
   1919 ./game/core/graphics/Screen.java
   2417 ./game/core/graphics/device/LGraphics.java
   3050 ./game/core/geom/AffineTransform.java
  68753 total

 

统计目录并按行数排序(按行文件名排序):

find . -name *.java | xargs wc -l | sort -k2

homer@ubuntu:~/workspace/android$ find . -name *.java | xargs wc -l | sort -k2
    210 ./game/action/ActionControl.java
    116 ./game/action/ActionEvent.java
     34 ./game/action/ActionListener.java
     ....
    178 ./game/utils/NumberUtils.java
    342 ./game/utils/RecordStoreUtils.java
     58 ./game/utils/ScreenUtils.java
    650 ./game/utils/StringUtils.java
  68753 total

统计文件行数

标签:

原文地址:http://www.cnblogs.com/dracohan/p/4218333.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!